diff --git a/Source/include/images.h b/Source/include/images.h index 7a127e1..c8f0924 100644 --- a/Source/include/images.h +++ b/Source/include/images.h @@ -31,6 +31,7 @@ extern const unsigned short bitmapWebSdrGradient[]; extern const unsigned short bitmapFilter[]; extern const unsigned short bitmapHadLogo[]; extern const unsigned short bitmapSMeter[]; +extern const unsigned short bitmapOff[]; extern const unsigned short oneSmall[]; extern const unsigned short twoSmall[]; diff --git a/Source/include/main.h b/Source/include/main.h index d8e1e43..381053e 100644 --- a/Source/include/main.h +++ b/Source/include/main.h @@ -32,6 +32,8 @@ #include "stm32f4xx_hal_dac.h" #include "stm32f4xx_hal_uart.h" #include "stm32f4xx_hal_usart.h" +#include "stm32f4xx_hal_pwr.h" + #endif #ifdef PSDR257 @@ -132,6 +134,7 @@ void Tick(void); void updateVfo(void); void zeroSampleBank(float *samples); +void shutDown(void); diff --git a/Source/src/images.c b/Source/src/images.c index dff347b..5f4ff76 100644 --- a/Source/src/images.c +++ b/Source/src/images.c @@ -843,3 +843,18 @@ const unsigned short tildeSmall[] ={ 0x553C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC400, 0x5538, 0xA2A0, 0x0000, 0x02B4, 0xE7FF, 0xFFFF, 0xFE30, 0x0000, // 0x0030 (48) pixels 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0040 (64) pixels 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; + +const unsigned short bitmapOff[] ={ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0010 (16) pixels + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 0x0020 (32) pixels + 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, // 0x0030 (48) pixels + 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, // 0x0040 (64) pixels + 0x0000, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0050 (80) pixels + 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0xFFFF, // 0x0060 (96) pixels + 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, // 0x0070 (112) pixels + 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, // 0x0080 (128) pixels + 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, // 0x0090 (144) pixels + 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00A0 (160) pixels + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00B0 (176) pixels + 0x0000, 0x0000, 0x0000, 0x0000, + }; diff --git a/Source/src/main.c b/Source/src/main.c index bd63841..e59d6ca 100644 --- a/Source/src/main.c +++ b/Source/src/main.c @@ -67,7 +67,7 @@ uint16_t filterKernelLength = 100; //what's a good value? How does it relate to uint16_t menuPos = 0; uint16_t menuEncoderTicks = 0; uint16_t menuLastPos = 1; -uint16_t menuCount = 11; +uint16_t menuCount = 12; uint32_t frequencyDialMultiplier = 1; long vfoAFrequency = 7030000; @@ -1174,7 +1174,8 @@ enum menuItems tenHertzMenuItem, hertzMenuItem, filterLowMenuItem, - filterHighMenuItem + filterHighMenuItem, + offMenuItem }; //enum menuItems @@ -1270,6 +1271,13 @@ void updateMenu() encoderLastPos = encoderPos; } break; + case offMenuItem: + encoderPos = getPos(); + if(encoderPos != encoderLastPos) + { + shutDown(); + } + break; default: break; } @@ -1454,6 +1462,11 @@ void updateDisplay(uint8_t force) afGainLast = afGain; } + if(force || (menuPos != menuLastPos && (menuPos == offMenuItem || menuLastPos == offMenuItem))) + { + Adafruit_GFX_drawColorBitmap(220, 10, bitmapOff, 20, 9, menuPos == offMenuItem ? MASKRED : MASKWHITE); + } + //I think I want to make this more like the Draw S Meter, where it only draws the parts that have changed. Also, I think I want to do gray pixels when half //way between values. if(redrawFilterBar) @@ -2156,6 +2169,11 @@ static void CPU_CACHE_Enable(void) SCB_EnableDCache(); } +void shutDown(void) +{ + HAL_PWR_EnterSTANDBYMode(); +} + #pragma GCC diagnostic pop // ----------------------------------------------------------------------------