From d4a465bb7fc8737df54ba49ea1b65396daecbdd2 Mon Sep 17 00:00:00 2001 From: dufourj Date: Thu, 25 May 2006 20:45:21 +0000 Subject: ES : - gestion du grub avec le LCD ; - gestion des servo moteurs des totems. --- n/es-2006/src/lcd.c | 10 +++++++--- n/es-2006/src/lcd.h | 2 +- n/es-2006/src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- n/es-2006/src/servo_motor.c | 9 +++++---- n/es-2006/src/servo_motor.h | 8 ++++---- 5 files changed, 61 insertions(+), 13 deletions(-) diff --git a/n/es-2006/src/lcd.c b/n/es-2006/src/lcd.c index 7908be5..ac8d96b 100644 --- a/n/es-2006/src/lcd.c +++ b/n/es-2006/src/lcd.c @@ -25,6 +25,8 @@ #include "lcd.h" #include "modules/twi/twi.h" +#include "modules/proto/proto.h" +#include "modules/utils/utils.h" uint8_t grub_greeting[32] = "Booting ! Press 1 > NFS 2 > Auto"; @@ -39,10 +41,10 @@ void lcd_init (void) } /* Print something on the LCD */ -inline void lcd_print (uint8_t *string, uint8_t size) +inline uint8_t lcd_print (uint8_t *string, uint8_t size) { /* Send to the LCD */ - twi_ms_send (TWI_LCD_ADDR, string, size); + return twi_ms_send (TWI_LCD_ADDR, string, size); } /* What key is pressed into the LCD keyboard ? */ @@ -56,6 +58,8 @@ uint8_t lcd_key (void) /* Tell the LCD we have seen the Grub ! */ void lcd_grub_booting (void) { - lcd_print (grub_greeting, 16); lcd_print (&grub_greeting[16], 16); + utils_delay_ms (4); + lcd_print (grub_greeting, 16); + utils_delay_ms (4); } diff --git a/n/es-2006/src/lcd.h b/n/es-2006/src/lcd.h index ebd93a0..4b20ad0 100644 --- a/n/es-2006/src/lcd.h +++ b/n/es-2006/src/lcd.h @@ -34,7 +34,7 @@ void lcd_init (void); /* Print something on the LCD */ -inline void lcd_print (uint8_t *string, uint8_t size); +uint8_t lcd_print (uint8_t *string, uint8_t size); /* What key is pressed into the LCD keyboard ? */ uint8_t lcd_key (void); diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c index e94235f..334d77f 100644 --- a/n/es-2006/src/main.c +++ b/n/es-2006/src/main.c @@ -27,6 +27,7 @@ #include "io.h" #include "modules/uart/uart.h" #include "modules/proto/proto.h" +#include "modules/uart/uart.h" #include "modules/utils/utils.h" #include "modules/utils/byte.h" @@ -74,6 +75,9 @@ uint8_t lcd_key_enable, lcd_key_freq; /* Enable stat for ack */ uint8_t main_ack_freq, main_ack_enable; +/* Grub enable */ +uint16_t grub_enable; + /** Call when we receive some data from proto (uart) */ void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) @@ -198,8 +202,9 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) /* Grub ! */ case c ('G', 0): + grub_enable = 2000; lcd_grub_booting (); - break; + return; /* tests primaires pour le barillet */ case c ('v',3): @@ -391,6 +396,44 @@ main (void) proto_send1b ('L', twi_buffer_read); } + if (grub_enable) + { + uint8_t ret; + grub_enable--; + utils_delay_ms (4); + switch (ret = lcd_key ()) + { + case 0x31: + /* NFS -> CR */ + uart0_putc (10); + utils_delay_ms (4); + lcd_print (" ", 16); + utils_delay_ms (4); + lcd_print (">>> NFS <<<", 16); + grub_enable = 0; + break; + case 0x32: + /* Autonomous -> v CR */ + uart0_putc ('v'); + uart0_putc (10); + utils_delay_ms (4); + lcd_print (" ", 16); + utils_delay_ms (4); + lcd_print (">> Automous <<", 16); + grub_enable = 0; + break; + case 0x0: + if (!grub_enable) + { + lcd_print (" ", 16); + utils_delay_ms (4); + utils_delay_ms (4); + lcd_print ("> Default NFS <", 16); + } + } + + } + /* gestion du barilet */ sequenceur_barillet (); diff --git a/n/es-2006/src/servo_motor.c b/n/es-2006/src/servo_motor.c index 9112067..84e4d80 100644 --- a/n/es-2006/src/servo_motor.c +++ b/n/es-2006/src/servo_motor.c @@ -41,7 +41,7 @@ #define SRVM_TOTEML_PIN 3 /* first totem */ #define SRVM_TOTEMR_PIN 2 /* second totem */ /** Table for the time spend by each servo in high position. */ -volatile uint8_t servo_time[3] = { SRVM_TRASH_POS_CLOSE, SRVM_LEFT_POS_IN, SRVM_RIGHT_POS_IN }; +volatile uint8_t servo_time[3] = { SRVM_TRASH_POS_CLOSE, SRVM_RIGHT_POS_IN, SRVM_LEFT_POS_IN }; /** Different states of this module. */ #define SRVM_STATE_SLEEP 0 @@ -89,11 +89,12 @@ servo_motor_set_pos (uint8_t servo_mask, uint8_t servo_pos) SRVM_TRASH_POS_CLOSE); /* Totem1 */ else if (num == 1) + UTILS_BOUND (servo_time[num], SRVM_RIGHT_POS_OUT, + SRVM_RIGHT_POS_IN); + /* Totem Left */ + else if (num == 2) UTILS_BOUND (servo_time[num], SRVM_LEFT_POS_IN, SRVM_LEFT_POS_OUT); - else if (num == 2) - UTILS_BOUND (servo_time[num], SRVM_RIGHT_POS_IN, - SRVM_RIGHT_POS_OUT); } } diff --git a/n/es-2006/src/servo_motor.h b/n/es-2006/src/servo_motor.h index adc5fc8..455ce4d 100644 --- a/n/es-2006/src/servo_motor.h +++ b/n/es-2006/src/servo_motor.h @@ -30,10 +30,10 @@ #include "common.h" /** All the states used to comunicate with this module. */ -#define SRVM_LEFT_POS_IN 40 -#define SRVM_LEFT_POS_OUT 143 -#define SRVM_RIGHT_POS_IN 40 -#define SRVM_RIGHT_POS_OUT 143 +#define SRVM_LEFT_POS_IN 95 +#define SRVM_LEFT_POS_OUT 130 +#define SRVM_RIGHT_POS_IN 78 +#define SRVM_RIGHT_POS_OUT 45 #define SRVM_TRASH_POS_OPEN 68 /* 44 */ #define SRVM_TRASH_POS_CLOSE 100 /* 64 */ -- cgit v1.2.3