
EET 3735 Rachid, Tyler, Ryan
Dependencies: BSP_DISCO_L476VG LCD_DISCO_L476VG mbed
Fork of DISCO_L476VG_leds_buttons by
Revision 2:1b6162cd96d4, committed 2018-04-05
- Comitter:
- carter7778
- Date:
- Thu Apr 05 22:42:33 2018 +0000
- Parent:
- 1:29e159d631f5
- Commit message:
- lcd will print which button on direction pad is pressed
Changed in this revision
diff -r 29e159d631f5 -r 1b6162cd96d4 BSP_DISCO_L476VG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_L476VG.lib Thu Apr 05 22:42:33 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/BSP_DISCO_L476VG/#472232f07925
diff -r 29e159d631f5 -r 1b6162cd96d4 LCD_DISCO_L476VG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_L476VG.lib Thu Apr 05 22:42:33 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/LCD_DISCO_L476VG/#6ac2ed34f595
diff -r 29e159d631f5 -r 1b6162cd96d4 main.cpp --- a/main.cpp Tue Jun 06 14:41:33 2017 +0200 +++ b/main.cpp Thu Apr 05 22:42:33 2018 +0000 @@ -1,95 +1,108 @@ + #include "mbed.h" - +#include "LCD_DISCO_L476VG.h" +LCD_DISCO_L476VG lcd; #define USE_PRINTF (1) - + uint8_t title_CENTER[]= " CENTER"; + uint8_t title_LEFT[]= " LEFT"; + uint8_t title_RIGHT[]= " RIGHT"; + uint8_t title_UP[]= " UP"; + uint8_t title_DOWN[]= " DOWN"; + // Joystick button InterruptIn center(JOYSTICK_CENTER); InterruptIn left(JOYSTICK_LEFT); InterruptIn right(JOYSTICK_RIGHT); InterruptIn up(JOYSTICK_UP); InterruptIn down(JOYSTICK_DOWN); - // LEDs DigitalOut led_green(LED1); DigitalOut led_red(LED2); - void center_released() { - led_green = 0; + led_green = 1; #if USE_PRINTF == 1 printf("center button released\n"); -#endif +#endif } - void center_pressed() { + led_green = 0; +#if USE_PRINTF == 1 + printf("center button pressed\n"); + + lcd.Clear(); + lcd. ScrollSentence(title_CENTER, 1,200); + lcd.Clear(); + + +#endif +} +void left_released() { led_green = 1; -#if USE_PRINTF == 1 - printf("center button pressed\n"); -#endif -} - -void left_released() { - led_green = 0; #if USE_PRINTF == 1 printf("left button released\n"); -#endif +#endif } - void left_pressed() { led_green = 1; -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 printf("left button pressed\n"); -#endif + + lcd.Clear(); + lcd. ScrollSentence(title_LEFT, 1,200); + lcd.Clear(); +#endif } - void right_released() { - led_green = 0; + led_green = 1; #if USE_PRINTF == 1 printf("right button released\n"); -#endif +#endif } - void right_pressed() { led_green = 1; -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 printf("right button pressed\n"); -#endif + lcd.Clear(); + lcd. ScrollSentence(title_RIGHT, 1,200); + lcd.Clear(); +#endif } - void up_released() { led_green = 0; #if USE_PRINTF == 1 printf("up button released\n"); -#endif +#endif } - void up_pressed() { led_green = 1; -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 printf("up button pressed\n"); -#endif + lcd.Clear(); + lcd. ScrollSentence(title_UP, 1,200); + lcd.Clear(); +#endif } - void down_released() { - led_green = 0; + led_green = 1; #if USE_PRINTF == 1 printf("down button released\n"); -#endif +#endif } - void down_pressed() { led_green = 1; -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 printf("down button pressed\n"); -#endif + lcd.Clear(); + lcd. ScrollSentence(title_DOWN, 1,200); + lcd.Clear(); +#endif } - int main() { - -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 int i = 0; printf("\nStart!\n"); #endif - + // Both rise and fall edges generate an interrupt center.fall(¢er_released); center.rise(¢er_pressed); @@ -101,19 +114,19 @@ up.rise(&up_pressed); down.fall(&down_released); down.rise(&down_pressed); - // Add pull-down on these pins // Warning: must be done AFTER edges setting left.mode(PullDown); right.mode(PullDown); up.mode(PullDown); down.mode(PullDown); - + while (1) { led_red = !led_red; wait(1.0); -#if USE_PRINTF == 1 +#if USE_PRINTF == 1 printf("main %d\n", i++); -#endif +#endif } } +