Permalink
Browse files

Merge branch 'master' of http://github.com/poelzi/OpenChronos

  • Loading branch information...
2 parents da30a5b + 1ec9a94 commit 1667cc34ea19a69bdaf386d568b704ee83ec7b70 @dkm dkm committed Jul 22, 2010
Showing with 100 additions and 62 deletions.
  1. +4 −0 TODO
  2. +1 −1 driver/display.h
  3. +1 −0 ezchronos.c
  4. +1 −1 logic/menu.c
  5. +65 −29 logic/phase_clock.c
  6. +2 −12 logic/phase_clock.h
  7. +15 −6 logic/rfsimpliciti.c
  8. +1 −0 logic/rfsimpliciti.h
  9. +2 −1 logic/test.c
  10. +8 −12 simpliciti/Applications/application/End_Device/main_ED_BM.c
View
4 TODO
@@ -7,6 +7,10 @@
* fix the eggtimer. it runs to slow (like 2 seconds per second...)
* merge eggtimer into stopwatch. to much shared code that blow the firmware
+== OPEN BUG ==
+* very hard to debug: when the battery is quite low, the sleep init mode fails. only way currently working
+ is to set "bug 1" in the sleep settings and skip the init phase (very bad).
+
== IN WORKS ==
* autosync before/after flash
View
@@ -293,7 +293,7 @@ extern volatile s_display_flags display;
#define LCD_UNIT_L1_K_MASK (BIT6)
#define LCD_UNIT_L1_M_MASK (BIT1)
#define LCD_UNIT_L1_I_MASK (BIT0)
-#define LCD_UNIT_L1_PER_S_MASK (BIT3)
+#define LCD_UNIT_L1_PER_S_MASK (BIT7)
#define LCD_UNIT_L1_PER_H_MASK (BIT2)
#define LCD_UNIT_L1_DEGREE_MASK (BIT1)
#define LCD_UNIT_L2_KCAL_MASK (BIT4)
View
@@ -320,6 +320,7 @@ void init_global_variables(void)
// ptrMenu_L2 = &menu_L2_Distance;
// ptrMenu_L2 = &menu_L2_Calories;
// ptrMenu_L2 = &menu_L2_Battery;
+// ptrMenu_L2 = &menu_L2_Phase;
// Assign LINE1 and LINE2 display functions
fptr_lcd_function_line1 = ptrMenu_L1->display_function;
View
@@ -253,7 +253,7 @@ const struct menu menu_L2_Battery =
const struct menu menu_L2_Phase =
{
FUNCTION(sx_phase), // direct function
- FUNCTION(dummy), // sub menu function
+ FUNCTION(mx_phase), // sub menu function
FUNCTION(display_phase_clock), // display function
FUNCTION(update_time), // new display data
&menu_L2_Rf,
View
@@ -64,6 +64,7 @@
#include "temperature.h"
#include "vti_ps.h"
#include "altitude.h"
+#include "user.h"
// *************************************************************************************************
@@ -116,22 +117,6 @@ unsigned char phase_clock_reply_count;
extern void (*fptr_lcd_function_line1)(u8 line, u8 update);
-// *************************************************************************************************
-// @fn reset_rf
-// @brief Reset SimpliciTI data.
-// @param none
-// @return none
-// *************************************************************************************************
-void reset_sleep(void)
-{
- // No connection
- sPhase.mode = SLEEP_OFF;
-
- // reset rf
- reset_rf();
-}
-
-
// *************************************************************************************************
// @fn sx_sleep
// @brief Start Sleep mode. Button DOWN connects/disconnects to access point.
@@ -152,10 +137,71 @@ void sx_phase(u8 line)
if (is_bluerobin()) return;
#endif
// Start SimpliciTI in tx only mode
- start_simpliciti_tx_only(SIMPLICITI_PHASE_CLOCK_START);
+ if(sPhase.bug)
+ start_simpliciti_tx_only(SIMPLICITI_PHASE_CLOCK);
+ else
+ start_simpliciti_tx_only(SIMPLICITI_PHASE_CLOCK_START);
+ //start_simpliciti_tx_only(SIMPLICITI_PHASE_CLOCK);
+}
+
+// *************************************************************************************************
+// @fn mx_phase
+// @brief Set program number to use
+// @param u8 line LINE2
+// @return none
+// *************************************************************************************************
+void mx_phase(u8 line){
+ s32 prog, bug;
+ u8 mode = 0;
+ prog = (s32)sPhase.program;
+ bug = (s32)sPhase.bug;
+ // Loop values until all are set or user breaks set
+ while(1)
+ {
+ // Idle timeout: exit without saving
+ if (sys.flag.idle_timeout) break;
+
+ // M2 (short): save, then exit
+ if (button.flag.num)
+ {
+ // Store local variables in global Eggtimer default
+ //sAlarm.hour = hours;
+ //sAlarm.minute = minutes;
+ sPhase.program = (u8)prog;
+ sPhase.bug = (u8)bug;
+ display.flag.line2_full_update = 1;
+ break;
+ }
+ if (button.flag.star)
+ mode = (mode+1)%2;
+
+ switch (mode) {
+ case 0:
+ //set_value(&prog, 2, 0, 0, 99, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1);
+ display_chars(LCD_SEG_L2_5_0, (u8 *)" PR ", SEG_ON);
+ set_value(&prog, 2, 0, 0, 99, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1);
+ break;
+ case 1:
+ display_chars(LCD_SEG_L2_5_0, (u8 *)" BUG", SEG_ON);
+ set_value(&bug, 2, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1);
+ break;
+ }
+ }
+
+ // Clear button flag
+ button.all_flags = 0;
+ display_phase_clock(line, DISPLAY_LINE_UPDATE_FULL);
}
-u8 diff(u8 x1, u8 x2) {
+
+
+// *************************************************************************************************
+// @fn diff
+// @brief calculates the smallest difference between two numbers
+// @param none
+// @return none
+// *************************************************************************************************
+static u8 diff(u8 x1, u8 x2) {
u8 b1 = x1 - x2;
if(b1 > 127)
b1 = x2 - x1;
@@ -165,7 +211,6 @@ u8 diff(u8 x1, u8 x2) {
return b1;
}
-
// *************************************************************************************************
// @fn phase_clock_calcpoint
// @brief calculate one data point for the out buffer
@@ -208,15 +253,6 @@ void display_phase_clock(u8 line, u8 update)
display_chars(LCD_SEG_L2_5_0, (u8 *)" SLEEP", SEG_ON);
}
}
-// *************************************************************************************************
-// @fn is_sleep
-// @brief Returns TRUE if SimpliciTI receiver is connected.
-// @param none
-// @return u8
-// *************************************************************************************************
-u8 is_sleep(void)
-{
- return (sPhase.mode != SLEEP_OFF);
-}
+
#endif /*CONFIG_PHASE_CLOCK*/
View
@@ -55,15 +55,7 @@ extern void send_data(void);
extern void display_phase_clock(u8 line, u8 update);
extern void sx_phase(u8 line);
-/*extern void sx_rf(u8 line);
-extern void sx_ppt(u8 line);
-extern void sx_sync(u8 line);
-extern void display_rf(u8 line, u8 update);
-extern void display_ppt(u8 line, u8 update);
-extern void display_sync(u8 line, u8 update);
-extern void send_smpl_data(u16 data);
-extern u8 is_rf(void);
-*/
+extern void mx_phase(u8 line);
extern void phase_clock_calcpoint();
@@ -116,9 +108,7 @@ typedef enum
// Global Variable section
struct SPhase
{
- // SIMPLICITI_OFF, SIMPLICITI_ACCELERATION, SIMPLICITI_BUTTONS
- simpliciti_mode_t mode;
-
+ u8 bug;
// current session id
u8 session;
// sleep program to start
View
@@ -75,7 +75,7 @@
void simpliciti_get_data_callback(void);
void start_simpliciti_tx_only(simpliciti_mode_t mode);
void start_simpliciti_sync(void);
-
+int simpliciti_get_rvc_callback(u8 len) __attribute__((noinline));
// *************************************************************************************************
// Defines section
@@ -223,10 +223,10 @@ void start_simpliciti_tx_only(simpliciti_mode_t mode)
start_as = 1;
}
#ifdef CONFIG_PHASE_CLOCK
- else if (mode == SIMPLICITI_PHASE_CLOCK_START)
+ else if (mode == SIMPLICITI_PHASE_CLOCK_START || mode == SIMPLICITI_PHASE_CLOCK)
{
- simpliciti_data[0] = SIMPLICITI_PHASE_CLOCK_START_EVENTS;
- start_as = 1;
+ if(mode == SIMPLICITI_PHASE_CLOCK)
+ start_as = 1;
display_symbol(LCD_ICON_RECORD, SEG_ON_BLINK_ON);
}
#endif
@@ -414,6 +414,8 @@ WDTCTL = WDTPW + WDTHOLD;
{
/* Initialisation phase. Get a Session id and send the
program wanted */
+ //display_chars(LCD_SEG_L1_3_2, itoa(packet_counter, 2, ' '), SEG_ON);
+
if(packet_counter == 30) {
simpliciti_flag |= SIMPLICITI_TRIGGER_STOP;
packet_counter = 0;
@@ -426,10 +428,11 @@ WDTCTL = WDTPW + WDTHOLD;
simpliciti_data[0] = SIMPLICITI_PHASE_CLOCK_START_EVENTS;
// put 2 bytes of watch id into the package
WATCH_ID(simpliciti_data, 1);
- // FIXME: TODO set program
+ // FIXME: TODO set program
simpliciti_data[3] = sPhase.program;
simpliciti_flag |= SIMPLICITI_TRIGGER_SEND_DATA | SIMPLICITI_TRIGGER_RECEIVE_DATA;
packet_counter ++;
+
}
else if (sRFsmpl.mode == SIMPLICITI_PHASE_CLOCK)
{
@@ -487,8 +490,13 @@ WDTCTL = WDTPW + WDTHOLD;
display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_ON);
display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_ON);
+ open_radio();
+
simpliciti_flag |= SIMPLICITI_TRIGGER_SEND_DATA;
- }
+ } else if (sPhase.out_nr == 0) {
+ // shutoff radio. no need to let it run for so long
+ close_radio();
+ }
sRFsmpl.timeout = SIMPLICITI_TIMEOUT;
@@ -556,6 +564,7 @@ int simpliciti_get_rvc_callback(u8 len)
simpliciti_data[0] = 0x00;
simpliciti_data[1] = 0x00;
simpliciti_data[2] = 0x00;
+ as_start();
return 1;
#endif
}
View
@@ -112,6 +112,7 @@ extern unsigned char simpliciti_flag;
// Extern section
extern void start_simpliciti_tx_only(simpliciti_mode_t mode);
+extern int simpliciti_get_rvc_callback(u8 len) __attribute__((noinline));
#endif /*RFSIMPLICITI_H_*/
View
@@ -35,14 +35,15 @@
// Test functions.
// *************************************************************************************************
-#ifdef CONFIG_TEST
// *************************************************************************************************
// Include section
// system
#include "project.h"
+#ifdef CONFIG_TEST
+
// driver
#include "display.h"
#include "vti_as.h"
@@ -61,8 +61,9 @@ extern uint8_t sInit_done;
extern void Timer0_A4_Delay(u16 ticks);
extern unsigned char simpliciti_payload_length;
+//extern txOpt_t simpliciti_options;
-extern int simpliciti_get_rvc_callback(uint8_t len);
+//extern int simpliciti_get_rvc_callback(uint8_t len);
// *************************************************************************************************
// Global Variable section
@@ -232,10 +233,11 @@ void simpliciti_main_tx_only(void)
// Send data when flag bit SIMPLICITI_TRIGGER_SEND_DATA is set
if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA))
{
- SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
// Acceleration / button events packets are 4 bytes long
- SMPL_SendOpt(sLinkID1, simpliciti_data, simpliciti_payload_length, SMPL_TXOPTION_NONE);
-
+ SMPL_SendOpt(sLinkID1, simpliciti_data, simpliciti_payload_length, SMPL_TXOPTION_NONE);
+ //SMPL_SendOpt(sLinkID1, simpliciti_data, simpliciti_payload_length, simpliciti_options);
+ // reset options to default
+ //simpliciti_options = SMPL_TXOPTION_NONE;
clearFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA);
}
// Receive data when flag bit SIMPLICITI_TRIGGER_RECEIVE_DATA is set
@@ -252,8 +254,8 @@ void simpliciti_main_tx_only(void)
// generate a ready to receive packet
ed_data[0] = SYNC_ED_TYPE_R2R;
ed_data[1] = 0xCB;
+
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
- NWK_DELAY(10);
// we try to receive 9 times by sending a R2R packet
for (i = 0; i < 10; i++) {
@@ -276,8 +278,8 @@ void simpliciti_main_tx_only(void)
break;
}
}
- Timer0_A4_Delay(CONV_MS_TO_TICKS(50));
}
+ Timer0_A4_Delay(CONV_MS_TO_TICKS(500));
}
}
@@ -329,12 +331,6 @@ void simpliciti_main_sync(void)
// Get radio ready. Radio wakes up in IDLE state.
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
- // send sync active package
- ed_data[0] = SYNC_ED_TYPE_R2R;
- ed_data[1] = 0xCB;
-
- SMPL_SendOpt(sLinkID1, ed_data, 2, SMPL_TXOPTION_NONE);
-
// Send 2 byte long ready-to-receive packet to stimulate host reply
ed_data[0] = SYNC_ED_TYPE_R2R;
ed_data[1] = 0xCB;

0 comments on commit 1667cc3

Please sign in to comment.