Power Off works! click Reset button to power on

This commit is contained in:
Paul Warren 2017-01-01 17:19:59 +11:00
parent 1381f544d0
commit 4b2fd072e9
4 changed files with 39 additions and 2 deletions

View file

@ -31,6 +31,7 @@ extern const unsigned short bitmapWebSdrGradient[];
extern const unsigned short bitmapFilter[]; extern const unsigned short bitmapFilter[];
extern const unsigned short bitmapHadLogo[]; extern const unsigned short bitmapHadLogo[];
extern const unsigned short bitmapSMeter[]; extern const unsigned short bitmapSMeter[];
extern const unsigned short bitmapOff[];
extern const unsigned short oneSmall[]; extern const unsigned short oneSmall[];
extern const unsigned short twoSmall[]; extern const unsigned short twoSmall[];

View file

@ -32,6 +32,8 @@
#include "stm32f4xx_hal_dac.h" #include "stm32f4xx_hal_dac.h"
#include "stm32f4xx_hal_uart.h" #include "stm32f4xx_hal_uart.h"
#include "stm32f4xx_hal_usart.h" #include "stm32f4xx_hal_usart.h"
#include "stm32f4xx_hal_pwr.h"
#endif #endif
#ifdef PSDR257 #ifdef PSDR257
@ -132,6 +134,7 @@ void Tick(void);
void updateVfo(void); void updateVfo(void);
void zeroSampleBank(float *samples); void zeroSampleBank(float *samples);
void shutDown(void);

View file

@ -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 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, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0040 (64) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; 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,
};

View file

@ -67,7 +67,7 @@ uint16_t filterKernelLength = 100; //what's a good value? How does it relate to
uint16_t menuPos = 0; uint16_t menuPos = 0;
uint16_t menuEncoderTicks = 0; uint16_t menuEncoderTicks = 0;
uint16_t menuLastPos = 1; uint16_t menuLastPos = 1;
uint16_t menuCount = 11; uint16_t menuCount = 12;
uint32_t frequencyDialMultiplier = 1; uint32_t frequencyDialMultiplier = 1;
long vfoAFrequency = 7030000; long vfoAFrequency = 7030000;
@ -1174,7 +1174,8 @@ enum menuItems
tenHertzMenuItem, tenHertzMenuItem,
hertzMenuItem, hertzMenuItem,
filterLowMenuItem, filterLowMenuItem,
filterHighMenuItem filterHighMenuItem,
offMenuItem
}; };
//enum menuItems //enum menuItems
@ -1270,6 +1271,13 @@ void updateMenu()
encoderLastPos = encoderPos; encoderLastPos = encoderPos;
} }
break; break;
case offMenuItem:
encoderPos = getPos();
if(encoderPos != encoderLastPos)
{
shutDown();
}
break;
default: default:
break; break;
} }
@ -1454,6 +1462,11 @@ void updateDisplay(uint8_t force)
afGainLast = afGain; 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 //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. //way between values.
if(redrawFilterBar) if(redrawFilterBar)
@ -2156,6 +2169,11 @@ static void CPU_CACHE_Enable(void)
SCB_EnableDCache(); SCB_EnableDCache();
} }
void shutDown(void)
{
HAL_PWR_EnterSTANDBYMode();
}
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------