oled stuff
This commit is contained in:
parent
5605a3d1d5
commit
33fcf6c080
@ -83,7 +83,7 @@ void MX_SPI3_Init(void)
|
||||
hspi3.Init.CLKPolarity = SPI_POLARITY_HIGH;
|
||||
hspi3.Init.CLKPhase = SPI_PHASE_2EDGE;
|
||||
hspi3.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
|
||||
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
|
@ -33,5 +33,8 @@ void oled_PrintEdge(void);
|
||||
void oled_Cursor(unsigned char cursor_column, unsigned char cursor_row);
|
||||
void oled_PrintLine(void);
|
||||
|
||||
void oledClear();
|
||||
void oledPrint(char msg[]);
|
||||
|
||||
|
||||
#endif /* OLED_H_ */
|
||||
|
@ -39,20 +39,27 @@ void my_setup_2() {
|
||||
logMsg("Application starting");
|
||||
|
||||
oledInit();
|
||||
oled_P8x16Str(0, 0, "App starting");
|
||||
|
||||
oledClear();
|
||||
oledPrint("App starting");
|
||||
|
||||
eepromInit();
|
||||
oledPrint("eeprom init");
|
||||
|
||||
wizInit();
|
||||
oledPrint("network init");
|
||||
|
||||
mqttCommInit();
|
||||
oledPrint("mqtt init");
|
||||
cmdHandlerInit();
|
||||
oledPrint("cmdhandler init");
|
||||
|
||||
frontendInit();
|
||||
frontendSetThreshold(240);
|
||||
oledPrint("frontend init");
|
||||
|
||||
mbusCommInit();
|
||||
oledPrint("Meterbus init");
|
||||
oledPrint("App running");
|
||||
}
|
||||
|
||||
void my_loop() {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <wizHelper.h>
|
||||
#include <mbusParserExt.h>
|
||||
#include <mqttComm.h>
|
||||
#include <oled.h>
|
||||
|
||||
#include <mbus/mbus-protocol.h>
|
||||
|
||||
@ -116,6 +117,7 @@ static void printError(t_mbusCommHandle *localMbusCommHandle) {
|
||||
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Error\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\"}",
|
||||
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio);
|
||||
oledPrint("Error");
|
||||
}
|
||||
|
||||
|
||||
@ -235,6 +237,7 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
||||
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio,
|
||||
keys[0], values[0], keys[1], values[1], keys[2], values[2], keys[3], values[3]);
|
||||
}
|
||||
oledPrint("Ok");
|
||||
mbus_data_record_free(data_var->record);
|
||||
} else {
|
||||
coloredMsg(LOG_RED, true, "mbc papf [%d] err: unable to parse frame", localMbusCommHandle->requestId);
|
||||
@ -520,6 +523,7 @@ static e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice) {
|
||||
mbusCommStats.requestCnt,
|
||||
mbusCommStats.errorCnt);
|
||||
|
||||
oledPrint(mbusDevice->deviceName);
|
||||
schAdd(handleRequestEngine, (void*) &mbusCommHandle, 0, 0);
|
||||
res = MBCRR_TRIGGERED;
|
||||
|
||||
|
@ -7,10 +7,14 @@
|
||||
#include <main.h>
|
||||
#include <spi.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <oled.h>
|
||||
#include <oled-fonts.h>
|
||||
#include <stm32f1xx_hal.h>
|
||||
|
||||
#include <logger.h>
|
||||
|
||||
|
||||
#define HIGH GPIO_PIN_SET
|
||||
@ -296,6 +300,8 @@ void oled_P6x8Char(unsigned char x,unsigned char y,unsigned char ch)
|
||||
|
||||
void oled_P6x8Str(unsigned char x,unsigned char y,char ch[])
|
||||
{
|
||||
coloredMsg(LOG_BLUE, false, "OLED: %d %d %s", x, y, ch);
|
||||
|
||||
unsigned char c=0,i=0,j=0;
|
||||
while (ch[j]!='\0')
|
||||
{
|
||||
@ -524,3 +530,35 @@ void loop()
|
||||
oled_P8x16Str(20,4,"Prototyping");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_LINES 8
|
||||
#define MAX_CHARS 21
|
||||
|
||||
static uint8_t currentLine = 0;
|
||||
static char lines[MAX_LINES+1][MAX_CHARS+1];
|
||||
|
||||
void oledClear() {
|
||||
oled_CLS();
|
||||
memset(lines, 0, sizeof(lines));
|
||||
currentLine = 0;
|
||||
}
|
||||
|
||||
void oledPrint(char msg[]) {
|
||||
if (currentLine < MAX_LINES) {
|
||||
memset(lines[currentLine], 0, MAX_CHARS);
|
||||
strncpy(lines[currentLine], msg, MAX_CHARS);
|
||||
|
||||
oled_P6x8Str(1, currentLine, lines[currentLine]);
|
||||
currentLine++;
|
||||
} else {
|
||||
for (uint8_t i = 1; i < MAX_LINES; i++) {
|
||||
memcpy(lines[i-1], lines[i], MAX_CHARS);
|
||||
oled_P6x8Str(1, i-1, lines[i-1]);
|
||||
}
|
||||
strncpy(lines[MAX_LINES - 1], msg, MAX_CHARS);
|
||||
memset(lines[MAX_LINES - 1] + strlen(msg), ' ', MAX_CHARS - strlen(msg) - 1);
|
||||
lines[MAX_LINES - 1][MAX_CHARS - 1] = 0;
|
||||
oled_P6x8Str(1, MAX_LINES - 1, lines[MAX_LINES - 1]);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
#include <string.h>
|
||||
#include <dhcp.h>
|
||||
#include <show.h>
|
||||
#include <oled.h>
|
||||
|
||||
wiz_NetInfo netInfo = {
|
||||
.mac = { 0x00, 0xA0, 0x57, 0x05, 0x3E, 0x0D },
|
||||
@ -75,6 +76,8 @@ static void wizDHCPAssign() {
|
||||
networkAvailable = true;
|
||||
show(LED_GREEN, ON);
|
||||
coloredMsg(LOG_BLUE, false, "wizda, network is available");
|
||||
|
||||
oledPrint("Address available");
|
||||
}
|
||||
|
||||
static void wizDHCPUpdate() {
|
||||
@ -114,6 +117,7 @@ static void wizPhyLinkHandler(void *handle) {
|
||||
lastStablePhyLink = phyLink;
|
||||
|
||||
if (phyLink == PHY_LINK_ON) {
|
||||
oledPrint("Link available");
|
||||
// start DHCP handler
|
||||
memset(dhcpBuffer, 0, DHCP_BUFFER_SIZE);
|
||||
reg_dhcp_cbfunc(wizDHCPAssign, wizDHCPUpdate, NULL);
|
||||
@ -126,6 +130,8 @@ static void wizPhyLinkHandler(void *handle) {
|
||||
|
||||
dhcpInitialized = true;
|
||||
} else {
|
||||
oledPrint("Link lost");
|
||||
|
||||
networkAvailable = false;
|
||||
show(LED_GREEN, BLINK);
|
||||
coloredMsg(LOG_BLUE, false, "wizplh, network is unavailable");
|
||||
|
Loading…
x
Reference in New Issue
Block a user