/[H8]/trunk/PIC/Demo trimmet/TFTPcDemo.c
ViewVC logotype

Diff of /trunk/PIC/Demo trimmet/TFTPcDemo.c

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

revision 109 by hedin, Mon May 28 10:13:48 2007 UTC revision 111 by hedin, Mon May 28 15:00:55 2007 UTC
# Line 5  Line 5 
5  #include "delay.h"  #include "delay.h"
6  #include "network.h"  #include "network.h"
7  #include "barcode.h"  #include "barcode.h"
8    #include "keyboard.h"
9    #include "MyI2C.h"
10    #include "xlcd.h"
11  #include <string.h>  #include <string.h>
12    
   
13  /*  /*
14   * This is used by other stack elements.   * This is used by other stack elements.
15   * Main application must define this and initialize it with   * Main application must define this and initialize it with
# Line 45  static void InitAppConfig(void); Line 47  static void InitAppConfig(void);
47  static void InitializeBoard(void);  static void InitializeBoard(void);
48  static void SetConfig(void);  static void SetConfig(void);
49    
50    // Skal fjernes
51    #define LCD_IC 0x74
52    void mylcd_write_byte(unsigned char data)
53    {
54            StartI2C(LCD_IC);
55            WriteI2CByte( data );
56            StopI2C();
57            Delay10us(1); //I2C spec's siger min 4.7 uSec mellem stop og næste start
58    }
59    
60    
61    
62  void main(void)  void main(void)
63  {  {
64      // Tick to blink SYSTEM led.      // Tick to blink SYSTEM led.
65      static TICK t = 0;      static TICK t = 0;
66        char i;
67        unsigned char numbers[20];
68        unsigned long amount;
69        unsigned char lcd_buffer[21];
70            short number_count = 0;
71            short produkt_amount = 0;
72            static bit hello = 0;
73            short varetal = 1;
74                    
75      TICK tick;      TICK tick;
76      TICK lastTick;      TICK lastTick;
# Line 77  void main(void) Line 96  void main(void)
96      StackInit();      StackInit();
97            
98      network_init();      network_init();
99        barcode_init();
100        InitI2C();
101        XLCDInit();
102            
103    
104    
105      /*      /*
# Line 102  void main(void) Line 124  void main(void)
124    
125      while(1)      while(1)
126      {      {
127                char keyboard_entered;
128                char network_error;
129    
130    
131          /*          /*
132           * Blink SYSTEM LED every second.           * Blink SYSTEM LED every second.
133           */           */
# Line 122  void main(void) Line 148  void main(void)
148           * For DHCP information, display how many times we have renewed the IP           * For DHCP information, display how many times we have renewed the IP
149           * configuration since last reset.           * configuration since last reset.
150           */           */
151            
152                                    //mylcd_write_byte(0b10100101);
153                      network_send_hello( 0x01 );  
154                                                if( (barcode_is_ready() || keyboard_entered) && !hello){
155                      strncpy(global_network_char, "12345678", 8);                                  network_send_hello(0x01);
156                                    hello = 1;
157                            }
158                            if (barcode_is_ready())
159                            {
160                                    for (i=0;i< barcode_get_length(); i++)
161                                    {
162                                            global_network_char[i] = global_barcode_buffer[i];
163                                            global_network_charlen = barcode_get_length();
164                                    }
165                                    barcode_reset();
166                                    network_send_scan_frame( varetal, global_network_charlen );
167                                    varetal = 1;
168    /*
169                                    XLCDClear();
170                                    XLCDGoto(1,0);
171                                    for (i=0;i< barcode_get_length(); i++)
172                                    {
173                                            XLCDPut(global_barcode_buffer[i]);
174                                    }
175    */
176                            }
177                            
178                            keyboard_entered = keyboard_read_safe();
179                            if( keyboard_entered )
180                            {
181                                    switch( keyboard_entered )
182                                    {
183                                            case 'A':
184                                            network_send_calc_total();
185                                            XLCDClear();
186                                            XLCDGoto(0,0);
187                                            for( i=0; i<global_network_charlen; i++ )
188                                            {
189                                                    XLCDPut(global_network_char[i]);
190                                            }
191                                            break;
192                                            
193                                            case 'B':
194                                            amount = atoi(numbers);
195                                            number_count = 0;
196                                            
197                                            network_send_cash_payed(amount);
198                                            network_send_goodbye();
199                                            hello = 0;
200                                            
201                                            sprintf(lcd_buffer,"%-5d", global_network_amount);
202                                            XLCDGoto(0,0);
203                                            XLCDPutString(lcd_buffer);
204                                            break;
205                                            
206                                            case 'C':
207                                            network_send_cancel_last();
208                                            break;
209                                            
210                                            case 'D':
211                                            network_send_cancel_all();                                      
212                                            break;
213                                            
214                                            case 'E':
215                                            for( i=0; i<number_count;i++ )
216                                            {
217                                                    global_network_char[i] = numbers[i];
218                                            }
219                                            network_send_scan_frame( varetal, number_count );
220                                            varetal = 1;
221                                            number_count = 0;
222                                            break;
223                                            
224                                            case 'F':
225                                            numbers[number_count] = 0; //nulterminering inden brug af atoi
226                                            varetal = atoi(numbers);
227                                            number_count = 0;
228                                            break;
229    
230                                            default:
231                                            numbers[number_count] = keyboard_entered;
232                                            
233                                            //numbers; // got to catch 0-9; 20 byte array.
234                                            number_count++; // amount of used bytes in numbers.
235                                    }
236                                    
237                            }
238    /*
239                            network_send_hello( 0x01 );
240    
241                            strncpy(global_network_char, "12345678", 8);
242                          network_send_scan_frame( 1, 8 ); //1x vare, stregkodelængde=8                          network_send_scan_frame( 1, 8 ); //1x vare, stregkodelængde=8
243                                                    
244                          strncpy(global_network_char, "87654444", 8);                          strncpy(global_network_char, "87654444", 8);
245                          network_send_scan_frame( 1, 8 ); //1x vare, stregkodelængde=8                          network_send_scan_frame( 1, 8 ); //1x vare, stregkodelængde=8
246                            
247                          network_send_calc_total();                          network_send_calc_total();
248                                                    
249                          network_send_cash_payed(50000);                          network_send_cash_payed(50000);
# Line 141  void main(void) Line 253  void main(void)
253                          network_send_cancel_all();                          network_send_cancel_all();
254                                                                                                    
255                          network_send_goodbye();                          network_send_goodbye();
256     */
257      }      }
258  }  }
259    
# Line 278  BOOL StringToIPAddress(char *str, IP_ADD Line 391  BOOL StringToIPAddress(char *str, IP_ADD
391      return (byteIndex == 3);      return (byteIndex == 3);
392  }  }
393    
394    void XLCDDelay15ms(void)
395    {
396        DelayMs(15);
397    }
398    void XLCDDelay4ms(void)
399    {
400        DelayMs(4);
401    }
402    
403    void XLCDDelay100us(void)
404    {
405        INTCON_GIEH = 0;
406        Delay10us(1);
407        INTCON_GIEH = 1;
408    }

Legend:
Removed from v.109  
changed lines
  Added in v.111

  ViewVC Help
Powered by ViewVC 1.1.20