implemented overloaded print & allowing blank lines
This commit is contained in:
parent
73d3b6f9c1
commit
253ed59793
116
display.ino
116
display.ino
@ -1,54 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
This is part of RadiationMapping
|
This is part of RadiationMapping
|
||||||
Copyright (C) 2024 Václav Šmejkal
|
Copyright (C) 2024 Václav Šmejkal
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <LiquidCrystal_I2C.h>
|
#include <LiquidCrystal_I2C.h>
|
||||||
|
|
||||||
LiquidCrystal_I2C lcd(0x27, 2, 16);
|
LiquidCrystal_I2C lcd(0x27, 2, 16);
|
||||||
|
|
||||||
namespace display
|
namespace display
|
||||||
{
|
{
|
||||||
void begin(void)
|
void begin(void)
|
||||||
{
|
{
|
||||||
//INIT THE LCD ITSELF
|
//INIT THE LCD ITSELF
|
||||||
Wire.begin(6, 7);
|
Wire.begin(6, 7);
|
||||||
lcd.init();
|
lcd.init();
|
||||||
|
|
||||||
//TURN ON THE BACKLIGHT
|
//TURN ON THE BACKLIGHT
|
||||||
lcd.backlight();
|
lcd.backlight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(String line_1, String line_2)
|
void print(String line_1, String line_2)
|
||||||
{
|
{
|
||||||
//CLEAR
|
print(line_1, line_2, false);
|
||||||
lcd.clear();
|
}
|
||||||
|
|
||||||
//LINE 1
|
void print(String line_1, String line_2, bool end)
|
||||||
lcd.setCursor(0, 0);
|
{
|
||||||
lcd.print(line_1);
|
//CLEAR
|
||||||
|
if (!end) lcd.clear();
|
||||||
//LINE 2
|
|
||||||
if (line_2 != NULL)
|
//LINE 1
|
||||||
{
|
if (line_1 != "")
|
||||||
lcd.setCursor(0, 1);
|
{
|
||||||
lcd.print(line_2);
|
lcd.setCursor(end ? 16 - line_1.length() : 0, 0);
|
||||||
}
|
lcd.print(line_1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
//LINE 2
|
||||||
|
if (line_2 != "")
|
||||||
|
{
|
||||||
|
lcd.setCursor(end ? 16 - line_2.length() : 0, 1);
|
||||||
|
lcd.print(line_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user