/[H9]/trunk/Embedded/main.c
ViewVC logotype

Diff of /trunk/Embedded/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 162 by hedin, Wed Dec 5 15:20:07 2007 UTC revision 167 by hedin, Wed Dec 5 16:11:12 2007 UTC
# Line 24  unsigned int global_serial_byte_counter Line 24  unsigned int global_serial_byte_counter
24  unsigned int global_emergency_counter = 600, global_time_interval = 3600;  unsigned int global_emergency_counter = 600, global_time_interval = 3600;
25  unsigned char global_temp = 0;  unsigned char global_temp = 0;
26    
27    unsigned char global_temp_update_display = 0;
28    
29  unsigned char global_message_buffer1[BUFFER];  unsigned char global_message_buffer1[BUFFER];
30  unsigned char global_message_buffer2[BUFFER];  unsigned char global_message_buffer2[BUFFER];
31  unsigned char global_message_buffer_length1;  unsigned char global_message_buffer_length1;
# Line 50  void timer1_interrupt(void); Line 52  void timer1_interrupt(void);
52  void on_recieve(void);  void on_recieve(void);
53  void on_initial_recieve(void);  void on_initial_recieve(void);
54  void sms_recieved(void);  void sms_recieved(void);
55  void send_sms(unsigned char* payload);  void send_sms(const unsigned char* payload);
56    
57    
58  void reset_recieve_buffer(void)  void reset_recieve_buffer(void)
# Line 218  void serial_send(void) Line 220  void serial_send(void)
220                  while(TRMT==0) ;                  while(TRMT==0) ;
221                  DelayMs(10);                  DelayMs(10);
222          }          }
223          DelayMs(250);          DelayMs(150);
224          global_serial_send[0] = 0;          global_serial_send[0] = 0;
225          DelayMs(250);          DelayMs(150);
226  }        }      
227    
228  ///////////////////////////////////////////////////////////////////////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////
# Line 241  void serial_recieved(void) Line 243  void serial_recieved(void)
243    
244          if ( global_serial_byte_counter < BUFFER) //Prevent buffer overrun          if ( global_serial_byte_counter < BUFFER) //Prevent buffer overrun
245                  global_serial_recieve_buffer[ global_serial_byte_counter++ ] = data_byte;       // fills the data_byte into our buffer.                  global_serial_recieve_buffer[ global_serial_byte_counter++ ] = data_byte;       // fills the data_byte into our buffer.
246            else
247            {
248                    global_serial_recieve_buffer[0] = 0;
249                    global_serial_byte_counter = 0;
250                    return;
251            }
252                    
253                    
254          if (data_byte == '\r')  // when we meet a '\r', the transmission is done, and we fill the constxt of          if (data_byte == '\r')  // when we meet a '\r', the transmission is done, and we fill the constxt of
# Line 276  void timer1_interrupt(void) Line 283  void timer1_interrupt(void)
283    
284  void update_lcd(void)  void update_lcd(void)
285  {  {
286          lcd_clear();          if(global_temp_update_display != global_time_counter)
287          lcd_goto(0x00);          {
288            //      lcd_clear();
289                    lcd_goto(0x00);
290                    
291          sprintf(global_lcd_buf, "Temp: %d", global_temp);                  sprintf(global_lcd_buf, "Temp: %3d", global_temp);
292          lcd_puts(global_lcd_buf);                  lcd_puts(global_lcd_buf);
293                    global_temp_update_display = global_time_counter;
294            }
295    
296  }  }
297                    
# Line 293  void send_update(void) Line 304  void send_update(void)
304          global_sms_counter++;          global_sms_counter++;
305  }        }      
306    
307  void send_sms(unsigned char* payload)  void send_sms(const unsigned char* payload)
308  {  {
309          sprintf(global_serial_send, "at+cmgs=\"%s\"\r", global_cell_nr);          sprintf(global_serial_send, "at+cmgs=\"%s\"\r", global_cell_nr);
310          serial_send();          serial_send();
311          sprintf(global_serial_send, "%s%c", payload, 0x1A);          sprintf(global_serial_send, "%s%c", payload, 0x1A);
312          serial_send();          serial_send();
313          DelayMs(250);          DelayMs(150);
314                    
315  }        }      
316    
# Line 494  void main() Line 505  void main()
505                          global_Pot_Hi = ADRESH;                          global_Pot_Hi = ADRESH;
506                          global_Pot_Lo = ADRESL;                          global_Pot_Lo = ADRESL;
507                          convertTemp();                          convertTemp();
508                          if (global_time_counter % 5 == 0)                          update_lcd();
                                 update_lcd();  
509                          GODONE = 1;                          GODONE = 1;
510                  }                  }
511          // Handels the recieve sms'es.          // Handels the recieve sms'es.

Legend:
Removed from v.162  
changed lines
  Added in v.167

  ViewVC Help
Powered by ViewVC 1.1.20