Skip to content

Commit

Permalink
lcd auto discovery do not work in a full station configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Oct 17, 2023
1 parent 4b7eebf commit b96ae13
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
50 changes: 50 additions & 0 deletions platformio/stima_v3/sensor_config_menu_sdcard/include/lcd_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**@file lcd_config.h */

/*********************************************************************
Copyright (C) 2017 Marco Baldinetti <m.baldinetti@digiteco.it>
authors:
Paolo Patruno <p.patruno@iperbole.bologna.it>
Marco Baldinetti <m.baldinetti@digiteco.it>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/

#ifndef _LCD_CONFIG_H
#define _LCD_CONFIG_H

/*!
\def LCD_I2C_ADDRESS
\brief LCD i2c address.
*/
#define LCD_I2C_ADDRESS (0x3F)

/*!
\def LCD_I2C_SECONDARY_ADDRESS
\brief Try this I2C address for LCD if LCD_I2C_ADDRESS fail.
*/
#define LCD_I2C_SECONDARY_ADDRESS (0x27)

/*!
\def LCD_COLUMNS
\brief Default LCD columns number.
*/
#define LCD_COLUMNS (20)

/*!
\def LCD_ROWS
\brief Default LCD rows number.
*/
#define LCD_ROWS (4)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sensors_config.h>
#include <ethernet_config.h>
#include "sensor_config.h"
#include "lcd_config.h"
#include <EEPROM.h>

#define LOG_LEVEL LOG_LEVEL_NOTICE
Expand Down Expand Up @@ -378,7 +379,7 @@ serialIn serial(Serial);
MENU_INPUTS(in,&irStream,&encStream,&encButton,&serial);


const panel panels[] MEMMODE={{0,0,20,4}};
const panel panels[] MEMMODE={{0,0,LCD_COLUMNS, LCD_ROWS}};
navNode* nodes[sizeof(panels)/sizeof(panel)];
panelsList pList(panels,nodes,1);

Expand All @@ -397,7 +398,7 @@ outputsList out(outputs,sizeof(outputs)/sizeof(menuOut*));//outputs list control

/*
MENU_OUTPUTS(out, MAX_DEPTH
,LIQUIDCRYSTAL_OUT(lcd,{0,0,20,4})
,LIQUIDCRYSTAL_OUT(lcd,{0,0,LCD_COLUMNS, LCD_ROWS})
,NONE
);
*/
Expand Down Expand Up @@ -2023,7 +2024,19 @@ void setup() {
pinMode(encBtn,INPUT_PULLUP);
encoder.begin();
encButton.begin();
lcd.begin(20,4);

lcd.setAddr(LCD_I2C_ADDRESS);
if(lcd.begin(LCD_COLUMNS, LCD_ROWS)) // non zero status means it was unsuccesful
{
LOGN(F(" Error initializing LCD primary addr"));

lcd.setAddr(LCD_I2C_SECONDARY_ADDRESS);
if(lcd.begin(LCD_COLUMNS, LCD_ROWS)) // non zero status means it was unsuccesful
{
LOGE(F(" Error initializing LCD"));
}
}

ir.begin();


Expand Down

0 comments on commit b96ae13

Please sign in to comment.