|
|
|
@ -6,11 +6,30 @@
|
|
|
|
#include "sdi_shield.h"
|
|
|
|
#include "sdi_shield.h"
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t EEMEM cam_saved;
|
|
|
|
uint8_t pgm = 0;
|
|
|
|
volatile uint8_t cam = 0;
|
|
|
|
uint8_t pvw = 0;
|
|
|
|
volatile uint8_t pgm = 0;
|
|
|
|
|
|
|
|
volatile uint8_t pvw = 0;
|
|
|
|
typedef struct {
|
|
|
|
volatile uint8_t valid = 0;
|
|
|
|
uint8_t cam;
|
|
|
|
|
|
|
|
uint8_t front_enabled;
|
|
|
|
|
|
|
|
uint8_t pvw_enabled;
|
|
|
|
|
|
|
|
} settings_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t setting_limits[sizeof(settings_t)] = {
|
|
|
|
|
|
|
|
16,
|
|
|
|
|
|
|
|
2,
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
volatile union{
|
|
|
|
|
|
|
|
settings_t settings;
|
|
|
|
|
|
|
|
uint8_t arr[sizeof(settings_t)];
|
|
|
|
|
|
|
|
} menu;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void* EEMEM settings_saved;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
volatile uint8_t menu_state = 0;
|
|
|
|
|
|
|
|
volatile uint8_t update = 1;
|
|
|
|
|
|
|
|
|
|
|
|
#define SDI_SHIELD_ADDR 0x84
|
|
|
|
#define SDI_SHIELD_ADDR 0x84
|
|
|
|
|
|
|
|
|
|
|
|
@ -19,27 +38,32 @@ volatile uint8_t valid = 0;
|
|
|
|
#define LENS_PGM_TALLY_PIN 2
|
|
|
|
#define LENS_PGM_TALLY_PIN 2
|
|
|
|
#define VF_FRONT_PGM_TALLY_PIN 3
|
|
|
|
#define VF_FRONT_PGM_TALLY_PIN 3
|
|
|
|
|
|
|
|
|
|
|
|
volatile uint8_t pvw_enabled = 1;
|
|
|
|
|
|
|
|
volatile uint8_t front_enabled = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void enc_init(){
|
|
|
|
void enc_init(){
|
|
|
|
PORTC |= (1<<2) | (1 << 3);
|
|
|
|
PORTC |= (1<<2) | (1 << 3);
|
|
|
|
PCICR |= (1<<PCIE1);
|
|
|
|
_delay_ms(10);
|
|
|
|
PCMSK1 |= (1<<PCINT10);
|
|
|
|
PCMSK1 |= (1<<PCINT10);
|
|
|
|
|
|
|
|
PCICR |= (1<<PCIE1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void btn_init(){
|
|
|
|
|
|
|
|
PORTB |= 1<<6; //PullUp
|
|
|
|
|
|
|
|
PCMSK0 |= (1<<PCINT6);
|
|
|
|
|
|
|
|
PCICR |= (1<<PCIE0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(void){
|
|
|
|
int main(void){
|
|
|
|
DDRB |= 1<<VF_BACK_PVW_TALLY_PIN; //uln glueh rot
|
|
|
|
DDRB |= 1<<VF_BACK_PVW_TALLY_PIN;
|
|
|
|
DDRB |= 1<<VF_BACK_PGM_TALLY_PIN; //uln glueh rot
|
|
|
|
DDRB |= 1<<VF_BACK_PGM_TALLY_PIN;
|
|
|
|
DDRB |= 1<<LENS_PGM_TALLY_PIN; //uln glueh rot
|
|
|
|
DDRB |= 1<<LENS_PGM_TALLY_PIN;
|
|
|
|
DDRB |= 1<<VF_FRONT_PGM_TALLY_PIN; //uln glueh rot
|
|
|
|
DDRB |= 1<<VF_FRONT_PGM_TALLY_PIN;
|
|
|
|
|
|
|
|
|
|
|
|
DDRD |= 1<<7; //enable backlight
|
|
|
|
DDRD |= 1<<7; //enable backlight
|
|
|
|
|
|
|
|
|
|
|
|
//PullUp BTN
|
|
|
|
eeprom_read_block(menu.arr, &settings_saved, sizeof(settings_t));
|
|
|
|
PORTB |= 1<<6;
|
|
|
|
if(menu.settings.cam > setting_limits[0])
|
|
|
|
|
|
|
|
menu.settings.cam = 0;
|
|
|
|
cam = eeprom_read_byte(&cam_saved);
|
|
|
|
enc_init();
|
|
|
|
|
|
|
|
btn_init();
|
|
|
|
|
|
|
|
|
|
|
|
lcd_init();
|
|
|
|
lcd_init();
|
|
|
|
lcd_on();
|
|
|
|
lcd_on();
|
|
|
|
@ -97,7 +121,6 @@ int main(void){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
enc_init();
|
|
|
|
|
|
|
|
sei();
|
|
|
|
sei();
|
|
|
|
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
while(1){
|
|
|
|
@ -107,60 +130,89 @@ int main(void){
|
|
|
|
shield_read_uint8(0x5001, &data_length);
|
|
|
|
shield_read_uint8(0x5001, &data_length);
|
|
|
|
if(data_length){
|
|
|
|
if(data_length){
|
|
|
|
uint8_t tally;
|
|
|
|
uint8_t tally;
|
|
|
|
shield_read_uint8(0x5100+cam, &tally);
|
|
|
|
shield_read_uint8(0x5100+menu.settings.cam, &tally);
|
|
|
|
pgm = !!(tally & (1<<0));
|
|
|
|
pgm = !!(tally & (1<<0));
|
|
|
|
pvw = !!(tally & (1<<1));
|
|
|
|
pvw = !!(tally & (1<<1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(pgm){
|
|
|
|
if(pgm){
|
|
|
|
DDRC |= 1<<1;
|
|
|
|
DDRC |= 1<<1;
|
|
|
|
if(front_enabled){
|
|
|
|
if(menu.settings.front_enabled){
|
|
|
|
PORTB |= (1<<LENS_PGM_TALLY_PIN);
|
|
|
|
PORTB |= (1<<LENS_PGM_TALLY_PIN);
|
|
|
|
PORTB |= (1<<VF_FRONT_PGM_TALLY_PIN);
|
|
|
|
PORTB |= (1<<VF_FRONT_PGM_TALLY_PIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PORTB |= (1<<VF_BACK_PGM_TALLY_PIN);
|
|
|
|
PORTB |= (1<<VF_BACK_PGM_TALLY_PIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else{
|
|
|
|
{
|
|
|
|
|
|
|
|
DDRC &= ~(1<<1);
|
|
|
|
DDRC &= ~(1<<1);
|
|
|
|
if(front_enabled){
|
|
|
|
|
|
|
|
PORTB &= ~(1<<LENS_PGM_TALLY_PIN);
|
|
|
|
|
|
|
|
PORTB &= ~(1<<VF_FRONT_PGM_TALLY_PIN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PORTB &= ~(1<<VF_BACK_PGM_TALLY_PIN);
|
|
|
|
PORTB &= ~(1<<VF_BACK_PGM_TALLY_PIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if((!pgm != !menu.settings.front_enabled)){
|
|
|
|
|
|
|
|
PORTB &= ~(1<<LENS_PGM_TALLY_PIN);
|
|
|
|
|
|
|
|
PORTB &= ~(1<<VF_FRONT_PGM_TALLY_PIN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(pvw & pvw_enabled){
|
|
|
|
if(pvw & menu.settings.pvw_enabled){
|
|
|
|
DDRC |= 1<<0;
|
|
|
|
DDRC |= 1<<0;
|
|
|
|
PORTB |= (1<<VF_BACK_PVW_TALLY_PIN);
|
|
|
|
PORTB |= (1<<VF_BACK_PVW_TALLY_PIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(!pvw | !menu.settings.pvw_enabled){
|
|
|
|
DDRC &= ~(1<<0);
|
|
|
|
DDRC &= ~(1<<0);
|
|
|
|
PORTB &= ~(1<<VF_BACK_PVW_TALLY_PIN);
|
|
|
|
PORTB &= ~(1<<VF_BACK_PVW_TALLY_PIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_cursor(0,0);
|
|
|
|
if(update){
|
|
|
|
lcd_printf("pgm: %d pvw: %d", pgm, pvw);
|
|
|
|
update = 0;
|
|
|
|
lcd_set_cursor(0,1);
|
|
|
|
lcd_set_cursor(0,0);
|
|
|
|
lcd_printf("cam: %d ", cam+1);
|
|
|
|
lcd_printf("cam: %d ", menu.settings.cam+1);
|
|
|
|
|
|
|
|
lcd_set_cursor(0,1);
|
|
|
|
|
|
|
|
lcd_printf("front: %d pvw: %d", menu.settings.front_enabled, menu.settings.pvw_enabled);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(menu_state){
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
lcd_disable_cursor();
|
|
|
|
|
|
|
|
lcd_disable_blinking();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
lcd_set_cursor(5,0);
|
|
|
|
|
|
|
|
lcd_enable_cursor();
|
|
|
|
|
|
|
|
lcd_enable_blinking();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
lcd_set_cursor(7, 1);
|
|
|
|
|
|
|
|
lcd_enable_cursor();
|
|
|
|
|
|
|
|
lcd_enable_blinking();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
lcd_set_cursor(14,1);
|
|
|
|
|
|
|
|
lcd_enable_cursor();
|
|
|
|
|
|
|
|
lcd_enable_blinking();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
_delay_ms(10);
|
|
|
|
_delay_ms(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ISR(PCINT0_vect){
|
|
|
|
|
|
|
|
if(!(PINB & (1<<6))){
|
|
|
|
|
|
|
|
menu_state=(menu_state+1)%4;
|
|
|
|
|
|
|
|
update=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ISR(PCINT1_vect){
|
|
|
|
ISR(PCINT1_vect){
|
|
|
|
if(PINC & (1<<2)){
|
|
|
|
if(menu_state){
|
|
|
|
if(PINC & (1<<3))
|
|
|
|
uint8_t dir = PINC & (1<<2)?1:-1;
|
|
|
|
cam--;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
cam++;
|
|
|
|
|
|
|
|
eeprom_write_byte(&cam_saved, cam);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(PINC & (1<<3))
|
|
|
|
if(PINC & (1<<3))
|
|
|
|
cam++;
|
|
|
|
menu.arr[menu_state-1]-=dir;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
cam--;
|
|
|
|
menu.arr[menu_state-1]+=dir;
|
|
|
|
eeprom_write_byte(&cam_saved, cam);
|
|
|
|
menu.arr[menu_state-1]%=setting_limits[menu_state-1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eeprom_update_block(menu.arr, &settings_saved, sizeof(settings_t));
|
|
|
|
|
|
|
|
update=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|