Wakeup Light with touch user interface, anti-aliased Font, SD card access and RTC usage on STM32F746NG-DISCO board

Dependencies:   BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src

Committer:
the_sz
Date:
Thu Oct 29 05:00:04 2015 +0000
Revision:
1:35e2ad5cd1fe
Child:
3:ecf7f1f8d749
led, debug led, display, debug port working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_sz 1:35e2ad5cd1fe 1 #include "WakeupLight.h"
the_sz 1:35e2ad5cd1fe 2
the_sz 1:35e2ad5cd1fe 3 #define COLOR_CREATE(_RED_,_GREEN_,_BLUE_,_WHITE_) (_RED_ | (_GREEN_ << 8) | (_BLUE_ << 16) | (_WHITE_ <<24))
the_sz 1:35e2ad5cd1fe 4 #define COLOR_RED(_COLOR_) (_COLOR_ & 0xFF)
the_sz 1:35e2ad5cd1fe 5 #define COLOR_GREEN(_COLOR_) ((_COLOR_ >> 8) & 0xFF)
the_sz 1:35e2ad5cd1fe 6 #define COLOR_BLUE(_COLOR_) ((_COLOR_ >> 16) & 0xFF)
the_sz 1:35e2ad5cd1fe 7 #define COLOR_WHITE(_COLOR_) ((_COLOR_ >> 24) & 0xFF)
the_sz 1:35e2ad5cd1fe 8
the_sz 1:35e2ad5cd1fe 9 #define LED_PERIOD 10
the_sz 1:35e2ad5cd1fe 10
the_sz 1:35e2ad5cd1fe 11 PwmOut ledBlue(PB_15);
the_sz 1:35e2ad5cd1fe 12 PwmOut ledRed(PH_6);
the_sz 1:35e2ad5cd1fe 13 PwmOut ledGreen(PB_4);
the_sz 1:35e2ad5cd1fe 14 PwmOut ledWhite(PA_15);
the_sz 1:35e2ad5cd1fe 15 Ticker ledTicker;
the_sz 1:35e2ad5cd1fe 16 int32_t ledAnimationStep;
the_sz 1:35e2ad5cd1fe 17 LED_ANIMATION_ENUM ledAnimation;
the_sz 1:35e2ad5cd1fe 18
the_sz 1:35e2ad5cd1fe 19 void LED_SetColor(int32_t color)
the_sz 1:35e2ad5cd1fe 20 {
the_sz 1:35e2ad5cd1fe 21 DPrintfCore("LED_SetColor: 0x%08X.\r\n",color);
the_sz 1:35e2ad5cd1fe 22
the_sz 1:35e2ad5cd1fe 23 ledRed.write(1.0 * COLOR_RED(color) / 255.0);
the_sz 1:35e2ad5cd1fe 24 ledGreen.write(1.0 * COLOR_GREEN(color) / 255.0);
the_sz 1:35e2ad5cd1fe 25 ledBlue.write(1.0 * COLOR_BLUE(color) / 255.0);
the_sz 1:35e2ad5cd1fe 26 ledWhite.write(1.0 * COLOR_WHITE(color) / 255.0);
the_sz 1:35e2ad5cd1fe 27 }
the_sz 1:35e2ad5cd1fe 28
the_sz 1:35e2ad5cd1fe 29 void LED_Callback()
the_sz 1:35e2ad5cd1fe 30 {
the_sz 1:35e2ad5cd1fe 31 int32_t color;
the_sz 1:35e2ad5cd1fe 32
the_sz 1:35e2ad5cd1fe 33 DPrintfCore("LED_Callback: Animation: %u, Step: %u.\r\n",ledAnimation,ledAnimationStep);
the_sz 1:35e2ad5cd1fe 34
the_sz 1:35e2ad5cd1fe 35 if (ledAnimation==LAE_WAKEUP)
the_sz 1:35e2ad5cd1fe 36 {
the_sz 1:35e2ad5cd1fe 37 if (ledAnimationStep<255)
the_sz 1:35e2ad5cd1fe 38 {
the_sz 1:35e2ad5cd1fe 39 ledAnimationStep++;
the_sz 1:35e2ad5cd1fe 40 color=COLOR_CREATE((ledAnimationStep/2),ledAnimationStep,0,0);
the_sz 1:35e2ad5cd1fe 41 LED_SetColor(color);
the_sz 1:35e2ad5cd1fe 42 }
the_sz 1:35e2ad5cd1fe 43 else if (ledAnimationStep<(255+180))
the_sz 1:35e2ad5cd1fe 44 {
the_sz 1:35e2ad5cd1fe 45 ledAnimationStep++;
the_sz 1:35e2ad5cd1fe 46
the_sz 1:35e2ad5cd1fe 47 color=COLOR_CREATE(128,255,0,(ledAnimationStep-255));
the_sz 1:35e2ad5cd1fe 48 LED_SetColor(color);
the_sz 1:35e2ad5cd1fe 49 }
the_sz 1:35e2ad5cd1fe 50 }
the_sz 1:35e2ad5cd1fe 51 }
the_sz 1:35e2ad5cd1fe 52
the_sz 1:35e2ad5cd1fe 53 void LED_StartAnimation(LED_ANIMATION_ENUM animation)
the_sz 1:35e2ad5cd1fe 54 {
the_sz 1:35e2ad5cd1fe 55 ledAnimationStep=0;
the_sz 1:35e2ad5cd1fe 56 ledAnimation=animation;
the_sz 1:35e2ad5cd1fe 57 }
the_sz 1:35e2ad5cd1fe 58
the_sz 1:35e2ad5cd1fe 59 void LED_Init(void)
the_sz 1:35e2ad5cd1fe 60 {
the_sz 1:35e2ad5cd1fe 61 ledRed.period_ms(LED_PERIOD);
the_sz 1:35e2ad5cd1fe 62 ledGreen.period_ms(LED_PERIOD);
the_sz 1:35e2ad5cd1fe 63 ledBlue.period_ms(LED_PERIOD);
the_sz 1:35e2ad5cd1fe 64 ledWhite.period_ms(LED_PERIOD);
the_sz 1:35e2ad5cd1fe 65
the_sz 1:35e2ad5cd1fe 66 LED_SetColor(COLOR_CREATE(0,0,0,0));
the_sz 1:35e2ad5cd1fe 67
the_sz 1:35e2ad5cd1fe 68 LED_StartAnimation(LAE_NONE);
the_sz 1:35e2ad5cd1fe 69
the_sz 1:35e2ad5cd1fe 70 ledTicker.attach(&LED_Callback,0.05);
the_sz 1:35e2ad5cd1fe 71 }