Commit 9d0e1e42 authored by Martin Vítek's avatar Martin Vítek
Browse files

Add basic structure for rendering on LCD

parent f14db376
#include "Render.h"
#include "HD44780.h"
const HD44780_config lcd_config = {PORTD, PIN2_bm, PIN3_bm, PIN4_bm, PIN5_bm, PIN6_bm, PIN7_bm};
Render::Render(): soldering_screen
{
"SET ACT",
"PWR ###########"
},
menu
{
"Go back",
"Show status",
"Settings"
},
settings
{
"Go back",
"Set standby tim",
"Set backlight",
"Set PID params"
},
status
{
"Go back",
"Uss: V",
"Ucc: V"
},
event(true),
in_menu(false),
in_status(false),
lcd(lcd_config)
{
lcd.init();
}
void Render::wellcome_screen()
{
//TODO: uart.send_string("\n\rSafe Soldering Station v1.0\n\r");
lcd.gotoxy_new(0,0);
lcd.write_text("Safe Soldering");
lcd.gotoxy_new(1,4);
lcd.write_text("Station v1.0");
_delay_ms(750);
lcd.clear();
lcd.gotoxy_new(0,0);
lcd.write_text("by OK1KVK.cz");
lcd.gotoxy_new(1,12);
lcd.write_text("2016");
_delay_ms(750);
lcd.clear();
}
void Render::rendering_handler()
{
if (event)
{
texts();
}
}
void Render::texts()
{
lcd.clear();
if (true)
{
lcd.gotoxy_new(0,1);
lcd.write_text(menu[0]);
lcd.gotoxy_new(1,1);
lcd.write_text(menu[1]);
arrows();
}
else if (in_status)
{
arrows();
}
else //Main screen
{
lcd.write_text(soldering_screen[0]);
lcd.gotoxy_new(1,0);
lcd.write_text(soldering_screen[1]);
}
event = false;
}
void Render::values()
{
}
void Render::arrows()
{
lcd.gotoxy_new(0,0);
lcd.write_char(DOUBLE_ARROW_RIGHT);
/*
lcd.gotoxy_new(0,15);
lcd.write_char(ARROW_UP);
lcd.gotoxy_new(1,15);
lcd.write_char(ARROW_DOWN);
*/
}
void Render::update_temperatures()
{
//lcd.got
}
......@@ -2,8 +2,7 @@
#include <stdint.h>
#define MAX_LENGHT 15
#include "HD44780.h"
enum symbols
{
......@@ -20,38 +19,34 @@ enum symbols
MI = 0xEA
};
//MAX "xxxxxxxxxxxxxxx"
struct soldering_screen
{
const char* temperatures = "SET ACT ";
const char* power = "PWR ###########";
const uint8_t y
};
struct menu
{
const char* show_status = "Show status";
const char* settings = "Settings";
};
struct settings
{
const char* standby = "Set standby time";
const char* backlight = "Set backlight";
const char* pdi = "Set PID params";
};
struct status_screen
{
const char* supply_voltage = "Uss: V";
const char* vcc_voltage = "Ucc: V";
};
class Render
{
private:
//Texts
const char soldering_screen[2][16];
const char menu[3][16];
const char settings[4][16];
const char status[3][16];
//Variables
bool event;
bool in_menu;
bool in_status;
//Instances
HD44780 lcd;
//Methods
void texts();
void values();
void arrows();
public:
Render();
void wellcome_screen();
void rendering_handler();
void update_temperatures();
};
......@@ -6,7 +6,6 @@
#include <stdint.h>
#include <util/delay.h>
const HD44780_config lcd_config = {PORTD, PIN2_bm, PIN3_bm, PIN4_bm, PIN5_bm, PIN6_bm, PIN7_bm};
//Global instance
SafeSolderingStation sss;
......@@ -14,9 +13,9 @@ SafeSolderingStation sss;
SafeSolderingStation::SafeSolderingStation() : led(PORTD, PIN0_bm),
heating(PORTC, PIN0_bm),
enc(),
lcd(lcd_config),
uart(),
backlight()
backlight(),
render()
{
}
......@@ -62,33 +61,13 @@ void SafeSolderingStation::init()
clock_init();
misc_pin_init();
uart.init();
lcd.init();
irq_init();
backlight.set_intensity(100);
}
void SafeSolderingStation::wellcome()
{
uart.send_string("\n\rSafe Soldering Station v1.0\n\r");
lcd.gotoxy_new(0,0);
lcd.write_text("Safe Soldering");
lcd.gotoxy_new(1,4);
lcd.write_text("Station v1.0");
_delay_ms(750);
lcd.clear();
lcd.gotoxy_new(0,0);
lcd.write_text("by OK1KVK.cz");
lcd.gotoxy_new(1,12);
lcd.write_text("2016");
_delay_ms(750);
lcd.clear();
}
void SafeSolderingStation::test_encoder()
{
/*
if (enc.event)
{
lcd.clear();
......@@ -103,10 +82,12 @@ void SafeSolderingStation::test_encoder()
enc.event = false;
}
*/
}
void SafeSolderingStation::test_backlight()
{
/*
if (enc.event)
{
if (enc.count >= 3) intensity++;
......@@ -118,10 +99,12 @@ void SafeSolderingStation::test_backlight()
lcd.gotoxy_new(0,6);
lcd.write_num(backlight.get_intensity());
}
*/
}
void SafeSolderingStation::test_adc()
{
/*
adc.start_conversion();
_delay_ms(20);
......@@ -131,4 +114,5 @@ void SafeSolderingStation::test_adc()
lcd.gotoxy_new(1,4);
//lcd.write_num(adc.adc_results[adc.SUPPLY_VOLTAGE]);
lcd.write_num(adc.results[adc.SUPPLY_VOLTAGE]);
*/
}
......@@ -8,6 +8,8 @@
#include "Uart.h"
#include "Backlight.h"
#include "ADC.h"
#include "Render.h"
class SafeSolderingStation
{
......@@ -24,16 +26,15 @@ class SafeSolderingStation
output led;
output heating;
encoder enc;
HD44780 lcd;
Uart uart;
Backlight backlight;
ADC adc;
Render render;
//Methods
SafeSolderingStation();
void init();
void wellcome();
void test_encoder();
void test_backlight();
......
......@@ -13,7 +13,8 @@ void find_character(uint8_t character);
int main()
{
sss.init();
sss.wellcome();
//sss.wellcome();
sss.render.wellcome_screen();
/*
sss.lcd.gotoxy_new(0,0);
......@@ -37,28 +38,12 @@ int main()
*/
uint8_t character = 255;
//find_character(character);
status_screen status;
soldering_screen solder;
sss.lcd.gotoxy_new(0,0);
//sss.lcd.write_text(status.supply_voltage);
sss.lcd.write_text(solder.temperature_current);
//sss.lcd.write_char(ARROW_UP);
sss.lcd.gotoxy_new(1,0);
//sss.lcd.write_text(status.supply_voltage);
sss.lcd.write_text(solder.temperature_set);
//sss.lcd.write_char(ARROW_DOWN);
for(;;)
{
//sss.test_encoder();
//sss.test_backlight();
//sss.test_adc();
sss.render.rendering_handler();
_delay_ms(100);
}
}
......@@ -81,11 +66,11 @@ void find_character(uint8_t character)
sss.enc.count = 0;
}
sss.lcd.gotoxy_new(0,0);
sss.lcd.write_num(character);
//sss.lcd.gotoxy_new(0,0);
//sss.lcd.write_num(character);
sss.lcd.gotoxy_new(1,0);
sss.lcd.write_char(character);
//sss.lcd.gotoxy_new(1,0);
//sss.lcd.write_char(character);
sss.enc.event = false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment