changeset 237:43f43ebe35df main

latest updates
author Bob Cook <bob@bobcookdev.com>
date Sat, 27 Dec 2014 08:42:01 -0800
parents 493f994c999a
children 0cd59a309606
files main/robots/odr-display/buttons.cpp main/robots/odr-display/canmsgs.cpp main/robots/odr-display/display.cpp main/robots/odr-display/func.h main/robots/odr-display/jamfile main/robots/odr-display/main.cpp main/robots/odr-display/status.cpp
diffstat 7 files changed, 106 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/main/robots/odr-display/buttons.cpp	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/buttons.cpp	Sat Dec 27 08:42:01 2014 -0800
@@ -66,19 +66,19 @@
     }
     else if ( ( PINC & ( 1 << PC4 ) ) == 0 )
     {
-        return button_up_e;
+        return button_right_e;
     }
     else if ( ( PINB & ( 1 << PB3 ) ) == 0 )
     {
-        return button_down_e;
+        return button_left_e;
     }
     else if ( ( PINB & ( 1 << PB4 ) ) == 0 )
     {
-        return button_left_e;
+        return button_up_e;
     }
     else if ( ( PINC & ( 1 << PC6 ) ) == 0 )
     {
-        return button_right_e;
+        return button_down_e;
     }
     else
     {
--- a/main/robots/odr-display/canmsgs.cpp	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/canmsgs.cpp	Sat Dec 27 08:42:01 2014 -0800
@@ -84,17 +84,14 @@
 
 // ----------------------------------------------------------------------------------------
 
-#if 0
-bool canmsg_send_command( uint8_t cmd, uint8_t data_1, uint8_t data_2 )
+static bool send_start_program( uint8_t pgm )
 {
     uint32_t msgid = can_build_message_id( can_node_odr_display,
                                            can_node_broadcast,
-                                           can_dataid_odr_display_cmd );
+                                           can_dataid_odr_start_pgm );
 
-    can_data_odrctl_button info;
-
-    info.button_1 = button_is_1_down();
-    info.button_2 = button_is_2_down();
+    can_data_pgm_selection  info;
+    info.pgm_id = pgm;
 
     if ( ! m1can_send( msgid, reinterpret_cast< uint8_t* >( &info ), sizeof( info ) ) )
     {
@@ -103,7 +100,27 @@
     
     return true;
 }
-#endif
+
+// ----------------------------------------------------------------------------------------
+
+bool canmsg_send_start_wander_pgm()
+{
+    return send_start_program( odr_pgm_wander );
+}
+
+// ----------------------------------------------------------------------------------------
+
+bool canmsg_send_start_line_pgm()
+{
+    return send_start_program( odr_pgm_straight_line );
+}
+
+// ----------------------------------------------------------------------------------------
+
+bool canmsg_send_start_smbox_pgm()
+{
+    return send_start_program( odr_pgm_small_box );
+}
 
 // ----------------------------------------------------------------------------------------
 
@@ -127,6 +144,7 @@
 
 static void update_yaw( const can_data_imu_data* data )
 {
+    status_got_imu_value();
     display_update_yaw( data->data );
 }
 
@@ -134,6 +152,7 @@
 
 static void update_pitch( const can_data_imu_data* data )
 {
+    status_got_imu_value();
     display_update_pitch( data->data );
 }
 
@@ -141,6 +160,7 @@
 
 static void update_roll( const can_data_imu_data* data )
 {
+    status_got_imu_value();
     display_update_roll( data->data );
 }
 
--- a/main/robots/odr-display/display.cpp	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/display.cpp	Sat Dec 27 08:42:01 2014 -0800
@@ -66,11 +66,11 @@
 //      4-| N 123 45.678    N 123 45.678 |-
 //      5-| W 123 45.678    W 123 45.678 |-
 //      6-|                              |-
-//      7-|   Y +000  P +00.0  R +00.0   |-
-//      8-|                              |-
+//      7-|  inertial measurement unit   |-
+//      8-|   Y +000  P +00.0  R +00.0   |-
 //      9-|                              |-
-//     20-|                              |-
-//      1-|                              |-
+//     20-|  +++++++ MENU ROW 1 +++++++  |-
+//      1-|  +++++++ MENU ROW 2 ++++++>  |-
 //      2-|                              |-
 //      3-|                              |-
 //      4-|                              |-
@@ -224,7 +224,7 @@
     str_write_pgm( PSTR("front obstacles"), 7, 7 );
     str_write_pgm( PSTR("location (--)"), 8, 10 );
     str_write_pgm( PSTR("origin         target"), 5, 13 );
-    str_write_pgm( PSTR("Y ----  P -----  R -----"), 3, 17 );
+    str_write_pgm( PSTR("inertial measurement unit"), 2, 17 );
 }
 
 // ----------------------------------------------------------------------------------------
@@ -372,6 +372,24 @@
 
 // ----------------------------------------------------------------------------------------
 
+static void update_imu_status()
+{
+    if ( ! status_is_imu_up() )
+    {
+        ili9340_write_pgm( PSTR("         offline          "),
+                           2, 18, ili9340_color_white, ili9340_color_red );
+    }
+    else
+    {
+        str_write_pgm( PSTR(" Y "),   2, 18 );
+        str_write_pgm( PSTR("  P "),  9, 18 );
+        str_write_pgm( PSTR("  R "), 18, 18 );
+        str_write( ' ', 27, 18 );
+    }
+}
+
+// ----------------------------------------------------------------------------------------
+
 void display_refresh()
 {
     update_heartbeat_flag();
@@ -379,6 +397,7 @@
     update_wheel_info();
     update_sonar_front_info();
     update_gps_status();
+    update_imu_status();
 
     ++g_spinner_count;
     g_spinner_count %= 4;
@@ -408,34 +427,6 @@
 
 // ----------------------------------------------------------------------------------------
 
-void display_update_button_1( bool down )
-{
-    if ( down )
-    {
-        ili9340_write_pgm( PSTR(" A "), 6, 15, ili9340_color_blue, ili9340_color_white );
-    }
-    else
-    {
-        ili9340_write_pgm( PSTR(" A "), 6, 15, ili9340_color_white, ili9340_color_blue );
-    }
-}
-
-// ----------------------------------------------------------------------------------------
-
-void display_update_button_2( bool down )
-{
-    if ( down )
-    {
-        ili9340_write_pgm( PSTR(" B "), 10, 15, ili9340_color_blue, ili9340_color_white );
-    }
-    else
-    {
-        ili9340_write_pgm( PSTR(" B "), 10, 15, ili9340_color_white, ili9340_color_blue );
-    }
-}
-
-// ----------------------------------------------------------------------------------------
-
 void display_update_wheel_speed( int8_t front, int8_t rear )
 {
     char buf[ 6 ];
@@ -544,7 +535,7 @@
     format_imu_value( value, buf );
     buf[ 4 ] = '\0';
 
-    str_write( buf, 5, 17 );
+    str_write( buf, 5, 18 );
 }
 
 // ----------------------------------------------------------------------------------------
@@ -558,7 +549,7 @@
     format_imu_value( value, buf );
     buf[ 1 ] = buf[ 0 ];
 
-    str_write( &buf[ 1 ], 13, 17 );
+    str_write( &buf[ 1 ], 13, 18 );
 }
 
 // ----------------------------------------------------------------------------------------
@@ -572,7 +563,7 @@
     format_imu_value( value, buf );
     buf[ 1 ] = buf[ 0 ];
 
-    str_write( &buf[ 1 ], 22, 17 );
+    str_write( &buf[ 1 ], 22, 18 );
 }
 
 // ----------------------------------------------------------------------------------------
@@ -679,6 +670,10 @@
         str_write( '1', 18, 10 );
         satellites -= 10;
     }
+    else
+    {
+        str_write( ' ', 18, 10 );
+    }
 
     str_write( '0' + satellites, 19, 10 );
 }
--- a/main/robots/odr-display/func.h	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/func.h	Sat Dec 27 08:42:01 2014 -0800
@@ -72,6 +72,8 @@
 bool status_is_sonar_front_enabled();
 bool status_is_gps_up();
 bool status_does_gps_have_fix();
+bool status_is_imu_up();
+void status_got_imu_value();
 
 // ----------------------------------------------------------------------------------------
 
@@ -97,8 +99,10 @@
 void display_update_longitude( int16_t degrees, int32_t min_thousandths );
 void display_update_gps_fix( uint8_t satellites );
 
-void display_update_button_1( bool down );
-void display_update_button_2( bool down );
+// ----------------------------------------------------------------------------------------
+
+void menu_init();
+void menu_refresh();
 
 // ----------------------------------------------------------------------------------------
 
@@ -107,7 +111,9 @@
 bool canmsg_send_emergency();
 bool canmsg_send_all_clear();
 bool canmsg_send_heartbeat();
-bool canmsg_send_button_status();
+bool canmsg_send_start_wander_pgm();
+bool canmsg_send_start_line_pgm();
+bool canmsg_send_start_smbox_pgm();
 bool canmsg_process_pending();
 
 // ----------------------------------------------------------------------------------------
--- a/main/robots/odr-display/jamfile	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/jamfile	Sat Dec 27 08:42:01 2014 -0800
@@ -38,6 +38,7 @@
       canmsgs.cpp
       display.cpp
       leds.cpp
+      menu.cpp
       status.cpp
       packages.avr.can.pkg
       packages.avr.device.pkg
--- a/main/robots/odr-display/main.cpp	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/main.cpp	Sat Dec 27 08:42:01 2014 -0800
@@ -51,6 +51,7 @@
 static const uint8_t trigger_check_emergency = ( 1 << 2 );
 static const uint8_t trigger_update_status   = ( 1 << 3 );
 static const uint8_t trigger_update_display  = ( 1 << 4 );
+static const uint8_t trigger_refresh_menu    = ( 1 << 5 );
 
 static volatile uint8_t g_triggers;
 
@@ -170,6 +171,7 @@
     //--    Initialize the display package (the LCD display).
 
     display_init();
+    menu_init();
 
     //--    Initialize the CAN related functions and hardware.
 
@@ -191,14 +193,16 @@
     //      check for button press: every 10 milliseconds
     //      led blink pattern: 60 milliseconds on, 150 off, 60 on
     //      check emergency status: every 100 milliseconds
+    //      refresh the menu: every 100 milliseconds
     //      update the system status and display every 500 milliseconds
     //      heartbeat: every 2.5 seconds
 
     button_update();
-
+    
     if ( count % 10 == 0 )
     {
         g_triggers |= trigger_check_emergency;
+        g_triggers |= trigger_refresh_menu;
     }
 
     if ( count % 50 == 0 )
@@ -358,6 +362,14 @@
             display_refresh();
         }
 
+        //--    Time to refresh the menu system?
+
+        if ( g_triggers & trigger_refresh_menu )
+        {
+            g_triggers &= ~trigger_refresh_menu;
+            menu_refresh();
+        }
+
         //--    Any pending CAN messages to receive/process?
 
         if ( ! canmsg_process_pending() )
--- a/main/robots/odr-display/status.cpp	Sun Jul 13 09:15:53 2014 -0700
+++ b/main/robots/odr-display/status.cpp	Sat Dec 27 08:42:01 2014 -0800
@@ -43,6 +43,7 @@
 static volatile uint8_t g_beats_without_motion_ctl;
 static volatile uint8_t g_beats_without_sonarfront;
 static volatile uint8_t g_beats_without_gps;
+static volatile uint8_t g_beats_without_imu;
 
 static volatile uint8_t g_status_flags;
 
@@ -56,10 +57,11 @@
 {
     // initalize the heartbeat watchdogs assuming no contact yet
     
-    g_beats_without_mgr = 100;
+    g_beats_without_mgr        = 100;
     g_beats_without_sonarfront = 100;
     g_beats_without_motion_ctl = 100;
-    g_beats_without_gps = 100;
+    g_beats_without_gps        = 100;
+    g_beats_without_imu        = 100;
 }
 
 // ----------------------------------------------------------------------------------------
@@ -139,6 +141,7 @@
     if ( g_beats_without_sonarfront < 200 ) { ++g_beats_without_sonarfront; }
     if ( g_beats_without_motion_ctl < 200 ) { ++g_beats_without_motion_ctl; }
     if ( g_beats_without_gps < 200 ) { ++g_beats_without_gps; }
+    if ( g_beats_without_imu < 200 ) { ++g_beats_without_imu; }
 
 #if 0
     //--    Has the ESTOP condition transitioned? Note we ignore this check if the
@@ -274,3 +277,18 @@
 
 // ----------------------------------------------------------------------------------------
 
+bool status_is_imu_up()
+{
+    // more than four seconds == down
+    return ( g_beats_without_imu < 8 );
+}
+
+// ----------------------------------------------------------------------------------------
+
+void status_got_imu_value()
+{
+    g_beats_without_imu = 0;
+}
+
+// ----------------------------------------------------------------------------------------
+