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

Add lot of things - e.g. starting adc conversion

parent 9d0e1e42
......@@ -61,6 +61,9 @@ class ADC
//Enable IRQ
ADCA.CH0.INTCTRL = ADC_CH_INTMODE_COMPLETE_gc | ADC_CH_INTLVL_LO_gc;
//Start on event from timer
//ADCA.EVCTRL = ADC_EVSEL_0123_gc | ADC_EVACT_CH0_gc;
//Enable ADC
ADCA.CTRLA |= ADC_ENABLE_bm;
}
......
#include "Render.h"
#include <util/delay.h>
#include "HD44780.h"
#include "SafeSolderingStation.h"
const HD44780_config lcd_config = {PORTD, PIN2_bm, PIN3_bm, PIN4_bm, PIN5_bm, PIN6_bm, PIN7_bm};
......@@ -33,6 +37,8 @@ Render::Render(): soldering_screen
event(true),
in_menu(false),
in_status(false),
screen(0),
row(0),
lcd(lcd_config)
{
lcd.init();
......@@ -70,7 +76,7 @@ void Render::texts()
{
lcd.clear();
if (true)
if (in_menu)
{
lcd.gotoxy_new(0,1);
lcd.write_text(menu[0]);
......@@ -104,7 +110,9 @@ void Render::values()
void Render::arrows()
{
lcd.gotoxy_new(0,0);
if (cursor_on_second_line) lcd.gotoxy_new(1,0);
else lcd.gotoxy_new(0,0);
lcd.write_char(DOUBLE_ARROW_RIGHT);
/*
......@@ -118,5 +126,11 @@ void Render::arrows()
void Render::update_temperatures()
{
//lcd.got
lcd.gotoxy_new(0, 4);
lcd.write_int_d(sss.set_temperature, ' ', 3);
lcd.write_char(DEGREE);
lcd.gotoxy_new(0, 12);
lcd.write_int_d(sss.adc.adc_results[sss.adc.THERMOCOUPLE], ' ', 3);
lcd.write_char(DEGREE);
}
......@@ -33,6 +33,10 @@ class Render
bool event;
bool in_menu;
bool in_status;
bool cursor_on_second_line;
uint8_t screen;
uint8_t row;
//Instances
HD44780 lcd;
......
......@@ -10,7 +10,8 @@
//Global instance
SafeSolderingStation sss;
SafeSolderingStation::SafeSolderingStation() : led(PORTD, PIN0_bm),
SafeSolderingStation::SafeSolderingStation() : set_temperature(200),
led(PORTD, PIN0_bm),
heating(PORTC, PIN0_bm),
enc(),
uart(),
......@@ -56,12 +57,20 @@ void SafeSolderingStation::irq_init()
sei();
}
void SafeSolderingStation::main_timer_init()
{
//244Hz
TCC1.CTRLA = TC_CLKSEL_DIV2_gc;
TCC1.INTCTRLA = TC_OVFINTLVL_LO_gc;
}
void SafeSolderingStation::init()
{
clock_init();
misc_pin_init();
uart.init();
irq_init();
main_timer_init();
backlight.set_intensity(100);
}
......
......@@ -18,10 +18,16 @@ class SafeSolderingStation
void clock_init();
void misc_pin_init();
void irq_init();
void main_timer_init();
uint8_t intensity;
public:
//Variables
uint8_t set_temperature;
//Objects
output led;
output heating;
......
......@@ -4,6 +4,13 @@
#include "SafeSolderingStation.h"
//Main timer
ISR(TCC1_OVF_vect)
{
sss.adc.start_conversion();
}
//Encoder button
ISR(PORTA_INT0_vect)
{
......
......@@ -2,6 +2,9 @@
#include <avr/interrupt.h>
//Main timer
ISR(TCC1_OVF_vect);
//Encoder
ISR(PORTA_INT0_vect);
ISR(PORTB_INT0_vect);
......
......@@ -44,7 +44,8 @@ int main()
for(;;)
{
sss.render.rendering_handler();
_delay_ms(100);
sss.render.update_temperatures();
_delay_ms(500);
}
}
......
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