LPCXpresso4337 and LPC General Purpose Shield OM13082 test.This example tests the display, potentiometer, Temperature Sensor, Keys, LEDs
Dependencies: LM75B PCAL955x ST7567 mbed
Revision 0:184f5fd4072b, committed 2016-09-12
- Comitter:
- FBSEletronica
- Date:
- Mon Sep 12 15:06:23 2016 +0000
- Commit message:
- test 1
Changed in this revision
diff -r 000000000000 -r 184f5fd4072b LM75B.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Mon Sep 12 15:06:23 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/neilt6/code/LM75B/#7ac462ba84ac
diff -r 000000000000 -r 184f5fd4072b PCAL955x.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCAL955x.lib Mon Sep 12 15:06:23 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/nxp_ip/code/PCAL955x/#fd7cfa821b6a
diff -r 000000000000 -r 184f5fd4072b ST7567.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ST7567.lib Mon Sep 12 15:06:23 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/MACRUM/code/ST7567/#743aff4786ba
diff -r 000000000000 -r 184f5fd4072b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 12 15:06:23 2016 +0000 @@ -0,0 +1,75 @@ +#include "mbed.h" +#include "ST7567.h" +#include "LM75B.h" +#include "PCAL9555.h" + +ST7567 lcd(D11, D13, D12, D9, D10); // mosi, sclk, reset, A0, nCS +LM75B sensor(D14,D15, LM75B::ADDRESS_4); +PCAL9555 gpio_exp(SDA, SCL); +GpioBusOut leds(gpio_exp, X1_4, X1_5, X1_6, X1_7); +GpioBusIn joystick(gpio_exp, X0_0, X0_1, X0_2, X0_3, X0_4); +AnalogIn pot(A3); + +enum led_num { + OM13082_LD1 = (1 << 0), + OM13082_LD2 = (1 << 1), + OM13082_LD3 = (1 << 2), + OM13082_LD4 = (1 << 3), +}; + +enum key_num { + Key_Up = (1 << X0_4), + Key_Down = (1 << X0_0), + Key_Right = (1 << X0_3), + Key_Left = (1 << X0_2), + Key_Center = (1 << X0_1), +}; + + +int main() +{ + + lcd.set_contrast(0x35); + lcd.cls(); + + lcd.locate(0, 1); + lcd.printf("EMBARCADOS CONTEST NXP"); + + + while(true) { // this is the third thread + lcd.locate(0, 2 + 8); + lcd.printf("POT = %.2f\n",(float)pot); + lcd.printf("Temp = %.1f C\n", sensor.temp()); + + + if(pot<0.25f){ + leds.write(0xF); + }else if((pot>=0.25f) & (pot<0.5f)){ + leds.write(~OM13082_LD1); + }else if((pot>=0.5f) & (pot<0.75f)){ + leds.write(~(OM13082_LD1|OM13082_LD2)); + } + else if((pot>=0.75f) & (pot<1.0f)){ + leds.write(~(OM13082_LD1|OM13082_LD2|OM13082_LD3)); + }else{ + leds.write(~(OM13082_LD1|OM13082_LD2|OM13082_LD3|OM13082_LD4)); + } + + int keys = joystick.read(); + + if ((keys & Key_Up) == 0) + lcd.printf("Key = Up \n"); + else if ((keys & Key_Down) == 0) + lcd.printf("Key = Down \n"); + else if ((keys & Key_Right) == 0) + lcd.printf("Key = Right \n"); + else if ((keys & Key_Left) == 0) + lcd.printf("Key = Left \n"); + else if ((keys & Key_Center) == 0) + lcd.printf("Key = Center \n"); + else + lcd.printf("Key = No Key \n"); + + wait(0.5); + } +}
diff -r 000000000000 -r 184f5fd4072b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 12 15:06:23 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897 \ No newline at end of file