1
0
forked from me/IronOS

Cleanup LCD on/off commands into buffer

This commit is contained in:
Ben V. Brown
2018-05-06 20:06:16 +10:00
parent 1fef2fb53a
commit 771f0a1b9e
5 changed files with 36 additions and 63 deletions

View File

@@ -9,8 +9,6 @@ SOURCE := $(shell find . -type f -name '*.c')
SOURCE_CPP := $(shell find . -type f -name '*.cpp') SOURCE_CPP := $(shell find . -type f -name '*.cpp')
SOURCES := $(shell find . -type f -name '*.c*') SOURCES := $(shell find . -type f -name '*.c*')
S_SRCS := $(shell find . -type f -name '*.s') S_SRCS := $(shell find . -type f -name '*.s')
CPPCHECK := cppcheck
CHECKFLAGS := -q --error-exitcode=1
APP_INC_DIR = ./inc APP_INC_DIR = ./inc
CMSIS_DEVICE_INC_DIR = ./CMSIS/device CMSIS_DEVICE_INC_DIR = ./CMSIS/device
@@ -34,7 +32,7 @@ HEXFILE_DIR=Hexfile
OUTPUT_DIR=Objects OUTPUT_DIR=Objects
# code optimisation ------------------------------------------------------------ # code optimisation ------------------------------------------------------------
OPTIM=-O2 -finline-small-functions -findirect-inlining -fdiagnostics-color OPTIM=-Os -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
# global defines --------------------------------------------------------------- # global defines ---------------------------------------------------------------
@@ -133,7 +131,11 @@ CXXFLAGS=$(CPUFLAGS) \
-fno-rtti \ -fno-rtti \
-fno-exceptions \ -fno-exceptions \
-fno-non-call-exceptions \ -fno-non-call-exceptions \
-fno-use-cxa-atexit \ -fno-use-cxa-atexit \
-fno-strict-aliasing \
-fno-rtti \
-fno-exceptions \
-fno-threadsafe-statics \
-T$(LDSCRIPT) -T$(LDSCRIPT)
@@ -175,7 +177,7 @@ OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S)) OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE)) OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
all: cppcheck.out.xml $(OUT_HEXFILE).hex all: $(OUT_HEXFILE).hex
# #
# The rule to create the target directory # The rule to create the target directory
@@ -212,8 +214,6 @@ $(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
@echo 'Finished building: $<' @echo 'Finished building: $<'
@echo ' ' @echo ' '
cppcheck.out.xml: $(SOURCES)
$(CPPCHECK) $(CHECKFLAGS) $^ -xml >$@
clean : clean :
rm -Rf $(OUTPUT_DIR) rm -Rf $(OUTPUT_DIR)

View File

@@ -57,7 +57,7 @@ private:
FRToSI2C* i2c; //i2c Pointer FRToSI2C* i2c; //i2c Pointer
const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer
uint8_t screenBuffer[14 + 96 + 96 + 10]; // The data buffer uint8_t screenBuffer[16 + 96 + 96 + 10]; // The data buffer
uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
uint8_t* secondStripPtr; //Pointers to the strips uint8_t* secondStripPtr; //Pointers to the strips
bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM) bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)

View File

@@ -32,7 +32,7 @@ void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
//RToS is active, run threading //RToS is active, run threading
//Get the mutex so we can use the I2C port //Get the mutex so we can use the I2C port
//Wait up to 1 second for the mutex //Wait up to 1 second for the mutex
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) { if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData, if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
Size, 5000) != HAL_OK) { Size, 5000) != HAL_OK) {
NVIC_SystemReset(); NVIC_SystemReset();
@@ -57,7 +57,7 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
//RToS is active, run threading //RToS is active, run threading
//Get the mutex so we can use the I2C port //Get the mutex so we can use the I2C port
//Wait up to 1 second for the mutex //Wait up to 1 second for the mutex
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) { if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize, if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
pData, Size, 5000) != HAL_OK) { pData, Size, 5000) != HAL_OK) {
NVIC_SystemReset(); NVIC_SystemReset();
@@ -86,7 +86,7 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t* pData, uint16_t Size) {
//RToS is active, run threading //RToS is active, run threading
//Get the mutex so we can use the I2C port //Get the mutex so we can use the I2C port
//Wait up to 1 second for the mutex //Wait up to 1 second for the mutex
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) { if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size) if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size)
!= HAL_OK) { != HAL_OK) {
NVIC_SystemReset(); NVIC_SystemReset();

View File

@@ -49,8 +49,8 @@ OLED::OLED(FRToSI2C* i2cHandle) {
currentFont = FONT_12; currentFont = FONT_12;
fontWidth = 12; fontWidth = 12;
inLeftHandedMode = false; inLeftHandedMode = false;
firstStripPtr = &screenBuffer[15]; firstStripPtr = &screenBuffer[16 + 1];
secondStripPtr = &screenBuffer[15 + 96]; secondStripPtr = &screenBuffer[16 + 1 + 96];
fontHeight = 16; fontHeight = 16;
fontWidth = 12; fontWidth = 12;
displayOffset = 0; displayOffset = 0;
@@ -70,22 +70,24 @@ void OLED::initialize() {
//Write out the buffer to the OLEd & call any rendering objects //Write out the buffer to the OLEd & call any rendering objects
void OLED::refresh() { void OLED::refresh() {
screenBuffer[0] = 0x80; screenBuffer[0] = 0x80;
screenBuffer[1] = 0x21; screenBuffer[1] = displayOnOffState ? 0xAF : 0xAE;
screenBuffer[2] = 0x80; screenBuffer[2] = 0x80;
screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide screenBuffer[3] = 0x21;
screenBuffer[4] = 0x80; screenBuffer[4] = 0x80;
screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide) screenBuffer[5] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
screenBuffer[6] = 0x80; /*Set COM Scan direction*/ screenBuffer[6] = 0x80;
screenBuffer[7] = inLeftHandedMode ? 0xC8 : 0xC0; screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
screenBuffer[8] = 0x80; //Set pages to rollover after 2 screenBuffer[8] = 0x80; /*Set COM Scan direction*/
screenBuffer[9] = 0x22; screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
screenBuffer[10] = 0x80; screenBuffer[10] = 0x80; //Set pages to rollover after 2
screenBuffer[11] = 0x00; //start page 0 screenBuffer[11] = 0x22;
screenBuffer[12] = 0x80; screenBuffer[12] = 0x80;
screenBuffer[13] = 0x01; screenBuffer[13] = 0x00; //start page 0
screenBuffer[14] = 0x40; //start of data marker screenBuffer[14] = 0x80;
screenBuffer[15] = 0x01;
screenBuffer[16] = 0x40; //start of data marker
i2c->Transmit( DEVICEADDR_OLED, screenBuffer, 14 + 96 * 2 + 1); i2c->Transmit( DEVICEADDR_OLED, screenBuffer, 16 + (96 * 2) + 1);
} }
@@ -150,16 +152,7 @@ void OLED::drawChar(char c, char PrecursorCommand) {
} }
void OLED::displayOnOff(bool on) { void OLED::displayOnOff(bool on) {
displayOnOffState = on;
if (on != displayOnOffState) {
uint8_t data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF }; //on
if (!on) {
data[3] = 0x10;
data[5] = 0xAE;
}
i2c->Transmit( DEVICEADDR_OLED, data, 6);
displayOnOffState = on;
}
} }
void OLED::setRotation(bool leftHanded) { void OLED::setRotation(bool leftHanded) {
@@ -172,7 +165,8 @@ void OLED::setRotation(bool leftHanded) {
OLED_Setup_Array[11] = 0xC0; OLED_Setup_Array[11] = 0xC0;
OLED_Setup_Array[19] = 0xA0; OLED_Setup_Array[19] = 0xA0;
} }
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, configLength); i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array,
configLength);
inLeftHandedMode = leftHanded; inLeftHandedMode = leftHanded;
} }
} }
@@ -340,7 +334,7 @@ void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
} }
void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
bool clear) { bool clear) {
//Draw this in 3 sections //Draw this in 3 sections
//This is basically a N wide version of vertical line //This is basically a N wide version of vertical line

View File

@@ -587,6 +587,10 @@ void showVersion(void) {
case 5: case 5:
lcd.print("Time: "); lcd.print("Time: ");
lcd.printNumber(xTaskGetTickCount() / 100, 5); lcd.printNumber(xTaskGetTickCount() / 100, 5);
break;
case 6:
lcd.print("Move: ");
lcd.printNumber(lastMovementTime / 100, 5);
break; break;
} }
@@ -597,7 +601,7 @@ void showVersion(void) {
return; return;
else if (b == BUTTON_F_SHORT) { else if (b == BUTTON_F_SHORT) {
screen++; screen++;
screen = screen % 6; screen = screen % 7;
} }
} }
} }
@@ -605,29 +609,6 @@ void showVersion(void) {
/* StartGUITask function */ /* StartGUITask function */
void startGUITask(void const *argument) { void startGUITask(void const *argument) {
i2cDev.FRToSInit(); i2cDev.FRToSInit();
/*
* Main program states:
*
* * Soldering (gui_solderingMode)
* -> Main loop where we draw temp, and animations
* --> User presses buttons and they goto the temperature adjust screen
* ---> Display the current setpoint temperature
* ---> Use buttons to change forward and back on temperature
* ---> Both buttons or timeout for exiting
* --> Long hold front button to enter boost mode
* ---> Just temporarily sets the system into the alternate temperature for
* PID control
* --> Long hold back button to exit
* --> Double button to exit
* * Settings Menu (gui_settingsMenu)
* -> Show setting name
* --> If no button press for > 3 Seconds, scroll description
* -> If user presses back button, adjust the setting
* -> Currently the same as 1.x (future to make more depth based)
*/
uint8_t animationStep = 0;
uint8_t tempWarningState = 0; uint8_t tempWarningState = 0;
bool buttonLockout = false; bool buttonLockout = false;
@@ -727,7 +708,6 @@ void startGUITask(void const *argument) {
lcd.displayOnOff(false); // turn lcd off when no movement lcd.displayOnOff(false); // turn lcd off when no movement
} else } else
lcd.displayOnOff(true); // turn lcd on lcd.displayOnOff(true); // turn lcd on
} else } else
lcd.displayOnOff(true); // turn lcd on - disabled motion sleep lcd.displayOnOff(true); // turn lcd on - disabled motion sleep
} else } else
@@ -787,7 +767,6 @@ void startGUITask(void const *argument) {
} }
lcd.refresh(); lcd.refresh();
animationStep++;
GUIDelay(); GUIDelay();
} }
} }