Compare commits

..

2 commits
eink ... master

Author SHA1 Message Date
43384d9277 Reduce save content frequency 2022-03-09 01:13:13 +01:00
19050fab18 Update Makefile 2022-03-06 14:42:58 +01:00
10 changed files with 50 additions and 178 deletions

3
.vscode/launch.json vendored
View file

@ -11,7 +11,8 @@
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/build/debug/voc-sensor.elf", "executable": "${workspaceFolder}/build/debug/voc-sensor.elf",
"servertype": "stutil", "servertype": "stutil",
"device": "STM32F103CB" "device": "STM32F103CB",
"runToMain": true
} }
] ]
} }

View file

@ -16,11 +16,9 @@ src \
SOURCES := \ SOURCES := \
src/BME68x-Sensor-API/bme68x.c \ src/BME68x-Sensor-API/bme68x.c \
src/oled-driver/fonts/dfi.cxx \ src/oled-driver/fonts/mono.cxx \
src/oled-driver/src/SSD1305.cxx \ src/oled-driver/src/SSD1305.cxx \
src/oled-driver/src/SSD1306.cxx \ src/oled-driver/src/SSD1306.cxx \
src/oled-driver/src/SSD1675a.cxx \
src/oled-driver/src/SSD1680.cxx \
src/oled-driver/src/Image.cxx \ src/oled-driver/src/Image.cxx \
src/oled-driver/src/Renderer.cxx \ src/oled-driver/src/Renderer.cxx \
src/bmeSPI.cxx \ src/bmeSPI.cxx \

View file

@ -60,7 +60,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)20000) #define configTOTAL_HEAP_SIZE ((size_t)6000)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0

View file

@ -60,10 +60,6 @@ void Error_Handler(void);
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define VocSensorCS_Pin GPIO_PIN_0 #define VocSensorCS_Pin GPIO_PIN_0
#define VocSensorCS_GPIO_Port GPIOA #define VocSensorCS_GPIO_Port GPIOA
#define EINK_BUSY_Pin GPIO_PIN_5
#define EINK_BUSY_GPIO_Port GPIOA
#define EINK_RS_Pin GPIO_PIN_2
#define EINK_RS_GPIO_Port GPIOB
#define DisplayDC_Pin GPIO_PIN_10 #define DisplayDC_Pin GPIO_PIN_10
#define DisplayDC_GPIO_Port GPIOB #define DisplayDC_GPIO_Port GPIOB
#define DisplayReset_Pin GPIO_PIN_11 #define DisplayReset_Pin GPIO_PIN_11

View file

@ -56,7 +56,7 @@ void MX_GPIO_Init(void)
HAL_GPIO_WritePin(VocSensorCS_GPIO_Port, VocSensorCS_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(VocSensorCS_GPIO_Port, VocSensorCS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, EINK_RS_Pin|DisplayDC_Pin|DisplayReset_Pin|DisplayCS_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, DisplayDC_Pin|DisplayReset_Pin|DisplayCS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : PC13 PC14 PC15 PC0 /*Configure GPIO pins : PC13 PC14 PC15 PC0
PC1 PC2 PC3 PC4 PC1 PC2 PC3 PC4
@ -84,33 +84,29 @@ void MX_GPIO_Init(void)
HAL_GPIO_Init(VocSensorCS_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(VocSensorCS_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PA1 PA2 PA3 PA4 /*Configure GPIO pins : PA1 PA2 PA3 PA4
PA6 PA7 PA8 PA9 PA5 PA6 PA7 PA8
PA10 PA11 PA12 PA15 */ PA9 PA10 PA11 PA12
PA15 */
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9 |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15; |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pins : PB0 PB1 PB2 PB3
GPIO_InitStruct.Pin = EINK_BUSY_Pin; PB4 PB5 PB6 PB7
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; PB8 PB9 */
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
HAL_GPIO_Init(EINK_BUSY_GPIO_Port, &GPIO_InitStruct); |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8|GPIO_PIN_9;
/*Configure GPIO pins : PB0 PB1 PB3 PB4
PB5 PB6 PB7 PB8
PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */ /*Configure GPIO pins : PBPin PBPin PBPin */
GPIO_InitStruct.Pin = EINK_RS_Pin|DisplayDC_Pin|DisplayReset_Pin|DisplayCS_Pin; GPIO_InitStruct.Pin = DisplayDC_Pin|DisplayReset_Pin|DisplayCS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

View file

@ -26,7 +26,7 @@ FREERTOS.IPParameters=Tasks01,configCHECK_FOR_STACK_OVERFLOW,FootprintOK,HEAP_NU
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;sensor,24,512,sensorTask,As external,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;sensor,24,512,sensorTask,As external,NULL,Dynamic,NULL,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1
FREERTOS.configTOTAL_HEAP_SIZE=20000 FREERTOS.configTOTAL_HEAP_SIZE=6000
FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1
File.Version=6 File.Version=6
GPIO.groupedBy= GPIO.groupedBy=
@ -42,19 +42,17 @@ Mcu.IPNb=6
Mcu.Name=STM32L152RCTx Mcu.Name=STM32L152RCTx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PA0-WKUP1 Mcu.Pin0=PA0-WKUP1
Mcu.Pin1=PA5 Mcu.Pin1=PB10
Mcu.Pin10=PA14 Mcu.Pin10=VP_SYS_VS_tim2
Mcu.Pin11=VP_FREERTOS_VS_CMSIS_V2 Mcu.Pin2=PB11
Mcu.Pin12=VP_SYS_VS_tim2 Mcu.Pin3=PB12
Mcu.Pin2=PB2 Mcu.Pin4=PB13
Mcu.Pin3=PB10 Mcu.Pin5=PB14
Mcu.Pin4=PB11 Mcu.Pin6=PB15
Mcu.Pin5=PB12 Mcu.Pin7=PA13
Mcu.Pin6=PB13 Mcu.Pin8=PA14
Mcu.Pin7=PB14 Mcu.Pin9=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin8=PB15 Mcu.PinsNb=11
Mcu.Pin9=PA13
Mcu.PinsNb=13
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32L152RCTx Mcu.UserName=STM32L152RCTx
@ -86,10 +84,6 @@ PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK PA14.Signal=SYS_JTCK-SWCLK
PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=EINK_BUSY
PA5.Locked=true
PA5.Signal=GPIO_Input
PB10.GPIOParameters=GPIO_Label PB10.GPIOParameters=GPIO_Label
PB10.GPIO_Label=DisplayDC PB10.GPIO_Label=DisplayDC
PB10.Signal=GPIO_Output PB10.Signal=GPIO_Output
@ -111,10 +105,6 @@ PB15.GPIOParameters=GPIO_Speed
PB15.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM PB15.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PB15.Mode=Full_Duplex_Master PB15.Mode=Full_Duplex_Master
PB15.Signal=SPI2_MOSI PB15.Signal=SPI2_MOSI
PB2.GPIOParameters=GPIO_Label
PB2.GPIO_Label=EINK_RS
PB2.Locked=true
PB2.Signal=GPIO_Output
PinOutPanel.RotationAngle=0 PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false

View file

@ -6,6 +6,9 @@
#include "oled-driver/SSDInterface.hpp" #include "oled-driver/SSDInterface.hpp"
constexpr size_t OledWidth = 128;
constexpr size_t OledPages = 4;
constexpr auto UsedSpiPeripherie = &hspi2; constexpr auto UsedSpiPeripherie = &hspi2;
extern QueueHandle_t spiMutex; extern QueueHandle_t spiMutex;
@ -16,22 +19,12 @@ extern void waitForSpiFinished();
class SSDSpiInterface : public SSDInterface class SSDSpiInterface : public SSDInterface
{ {
public: public:
void waitUntilIdle() override
{
while (!readBusyPin())
{
vTaskDelay(pdMS_TO_TICKS(10));
}
}
//--------------------------------------------------------------------------------------------------
void writeCommand(uint8_t cmd) override void writeCommand(uint8_t cmd) override
{ {
xSemaphoreTake(spiMutex, portMAX_DELAY); xSemaphoreTake(spiMutex, portMAX_DELAY);
setCommandPin(); setCommandPin();
setChipSelect(true); setChipSelect(true);
// vTaskDelay(1);
HAL_SPI_Transmit_DMA(UsedSpiPeripherie, &cmd, 1); HAL_SPI_Transmit_DMA(UsedSpiPeripherie, &cmd, 1);
waitForSpiFinished(); waitForSpiFinished();
setChipSelect(false); setChipSelect(false);
@ -46,7 +39,6 @@ public:
setDataPin(); setDataPin();
setChipSelect(true); setChipSelect(true);
// vTaskDelay(1);
HAL_SPI_Transmit_DMA(UsedSpiPeripherie, &data, 1); HAL_SPI_Transmit_DMA(UsedSpiPeripherie, &data, 1);
waitForSpiFinished(); waitForSpiFinished();
setChipSelect(false); setChipSelect(false);
@ -57,8 +49,8 @@ public:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void writeData(const uint8_t *data, unsigned int length) override void writeData(const uint8_t *data, unsigned int length) override
{ {
// if (length > OledWidth * OledPages) if (length > OledWidth * OledPages)
// return; return;
xSemaphoreTake(spiMutex, portMAX_DELAY); xSemaphoreTake(spiMutex, portMAX_DELAY);
@ -90,10 +82,4 @@ private:
HAL_GPIO_WritePin(DisplayCS_GPIO_Port, DisplayCS_Pin, HAL_GPIO_WritePin(DisplayCS_GPIO_Port, DisplayCS_Pin,
state ? GPIO_PIN_RESET : GPIO_PIN_SET); state ? GPIO_PIN_RESET : GPIO_PIN_SET);
} }
//--------------------------------------------------------------------------------------------------
bool readBusyPin()
{
return HAL_GPIO_ReadPin(EINK_BUSY_GPIO_Port, EINK_BUSY_Pin) == GPIO_PIN_SET;
}
}; };

View file

@ -259,7 +259,7 @@ void printBmeSensorData()
renderer.drawVerticalLine(OledWidth - MaxTextWidth - 2, 0, OledPages - 1); renderer.drawVerticalLine(OledWidth - MaxTextWidth - 2, 0, OledPages - 1);
if (iaqAccuracy == 0) if (iaqAccuracy == 0)
snprintf(buffer, MaximumChars, "IAQ:---\n---ppm\n"); snprintf(buffer, MaximumChars, "IAQ:---\n----ppm\n");
else else
snprintf(buffer, MaximumChars, "IAQ:%d\n%dppm\n", snprintf(buffer, MaximumChars, "IAQ:%d\n%dppm\n",
static_cast<int>(iaq), // static_cast<int>(iaq), //
@ -320,12 +320,14 @@ void writeStateToEeprom()
extern "C" void sensorTask(void *) extern "C" void sensorTask(void *)
{ {
initDisplay(); initDisplay();
vTaskSuspend(nullptr);
bmeSensorInit(); bmeSensorInit();
readStateFromEeprom(); readStateFromEeprom();
uint16_t counter = 0; constexpr auto TaskDelay = 10;
constexpr auto SaveContentDelay = 12 * 60 * 60 * 1000;
constexpr auto SaveContentDelayCounts = SaveContentDelay / TaskDelay;
uint32_t counter = 0;
while (1) while (1)
{ {
@ -333,13 +335,13 @@ extern "C" void sensorTask(void *)
bsecRun(); bsecRun();
printBmeSensorData(); printBmeSensorData();
if (counter++ >= 1000) if (counter++ >= SaveContentDelayCounts)
{ {
counter = 0; counter = 0;
initDisplay(); initDisplay();
writeStateToEeprom(); writeStateToEeprom();
} }
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelay(pdMS_TO_TICKS(TaskDelay));
} }
} }

View file

@ -5,19 +5,13 @@
// #include "BSEC/bsec_integration.h" // #include "BSEC/bsec_integration.h"
#include "SSDSpiInterface.hpp" #include "SSDSpiInterface.hpp"
#include "oled-driver/DualRenderer.hpp" #include "oled-driver/Renderer.hpp"
#include "oled-driver/SSD1306.hpp" #include "oled-driver/SSD1306.hpp"
#include "oled-driver/fonts/dfi.hpp"
#include "oled-driver/SSD1680.hpp"
// oled display // oled display
SSDSpiInterface ssdSpiInterface; SSDSpiInterface ssdSpiInterface;
SSD1680 test(ssdSpiInterface);
SSD1306 display(ssdSpiInterface); SSD1306 display(ssdSpiInterface);
DualRenderer renderer(296, 152, test); Renderer renderer(OledWidth, OledPages, display);
QueueHandle_t spiMutex = xSemaphoreCreateMutex(); QueueHandle_t spiMutex = xSemaphoreCreateMutex();
QueueHandle_t spiBinary = xSemaphoreCreateBinary(); QueueHandle_t spiBinary = xSemaphoreCreateBinary();
@ -26,100 +20,10 @@ QueueHandle_t spiBinary = xSemaphoreCreateBinary();
void initDisplay() void initDisplay()
{ {
HAL_GPIO_WritePin(DisplayReset_GPIO_Port, DisplayReset_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(DisplayReset_GPIO_Port, DisplayReset_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(EINK_RS_GPIO_Port, EINK_RS_Pin, GPIO_PIN_RESET); vTaskDelay(pdMS_TO_TICKS(1));
HAL_GPIO_WritePin(DisplayReset_GPIO_Port, DisplayReset_Pin, GPIO_PIN_SET);
vTaskDelay(pdMS_TO_TICKS(1));
vTaskDelay(pdMS_TO_TICKS(100));
// HAL_GPIO_WritePin(DisplayReset_GPIO_Port, DisplayReset_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(EINK_RS_GPIO_Port, EINK_RS_Pin, GPIO_PIN_SET);
vTaskDelay(pdMS_TO_TICKS(100));
test.selectLut(SSD1680::LutSelection::Red);
test.init();
renderer.black.setFont(fontDfi);
renderer.black.clearAll();
renderer.red.clearAll();
if (true)
{
test.selectLut(SSD1680::LutSelection::None);
test.init();
renderer.dualRender();
test.deepSleep(1);
return;
}
constexpr auto aL = Renderer::Alignment::Left;
constexpr auto aC = Renderer::Alignment::Center;
constexpr auto aR = Renderer::Alignment::Right;
size_t page = 0;
size_t maxNumberPixels = 0;
size_t result = 0;
bool scroll = false;
if (!scroll)
{
renderer.black.print({0, page}, "9", aL, 2);
renderer.black.print({20, page}, "Neustädter See", aL, 2);
renderer.black.print({296, page}, "jetzt", aR, 2);
page += 2;
}
renderer.black.print({0, page}, "1", aL, 2);
renderer.black.print({20, page}, "Sudenburg", aL, 2);
renderer.black.print({296, page}, "1min", aR, 2);
page += 2;
renderer.black.print({0, page}, "10", aL, 2);
renderer.black.print({20, page}, "Barleber See", aL, 2);
renderer.black.print({296, page}, "2min", aR, 2);
page += 2;
renderer.black.print({0, page}, "1", aL, 2);
renderer.black.print({20, page}, "Kannenstieg", aL, 2);
result = renderer.black.print({296, page}, "5min", aR, 2);
maxNumberPixels = std::max(maxNumberPixels, result);
page += 2;
renderer.black.print({0, page}, "9", aL, 2);
renderer.black.print({20, page}, "Reform", aL, 2);
result = renderer.black.print({296, page}, "55min", aR, 2);
maxNumberPixels = std::max(maxNumberPixels, result);
page += 2;
renderer.black.print({0, page}, "10", aL, 2);
renderer.black.print({20, page}, "Rothensee", aL, 2);
result = renderer.black.print({296, page}, "107min", aR, 2);
maxNumberPixels = std::max(maxNumberPixels, result);
page += 2;
renderer.red.print({0, page}, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", aL, 2);
page = scroll ? 2 : 3;
const auto PositionX = 296 - maxNumberPixels - 4;
result = renderer.black.print({PositionX, page}, ")", aR, 2);
auto result2 = renderer.red.print({PositionX - result, page}, "-8", aR, 2);
renderer.black.print({PositionX - result - result2, page}, "(", aR, 2);
page += 2;
result = renderer.black.print({PositionX, page}, ")", aR, 2);
result2 = renderer.red.print({PositionX - result, page}, "+2", aR, 2);
renderer.black.print({PositionX - result - result2, page}, "(", aR, 2);
page += 2;
result = renderer.black.print({PositionX, page}, ")", aR, 2);
result2 = renderer.red.print({PositionX - result, page}, "+22", aR, 2);
renderer.black.print({PositionX - result - result2, page}, "(", aR, 2);
page += 2;
renderer.dualRender();
test.deepSleep(1);
/*
display.setDisplayState(SSD1306::DisplayState::Off); display.setDisplayState(SSD1306::DisplayState::Off);
display.setMultiplexRatio(OledPages * 8 - 1); display.setMultiplexRatio(OledPages * 8 - 1);
display.setComPinConfig(false, false); display.setComPinConfig(false, false);
@ -135,7 +39,6 @@ void initDisplay()
display.setColumnAddress(0, OledWidth - 1); // columns from 0 to 127 display.setColumnAddress(0, OledWidth - 1); // columns from 0 to 127
display.setDisplayState(SSD1306::DisplayState::On); display.setDisplayState(SSD1306::DisplayState::On);
*/
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

@ -1 +1 @@
Subproject commit 2be16647b4431014c75ae8d0f46dbfb24772d2ad Subproject commit 95f315a0764640e542031c3307565e5b11f902ff