/[H8]/trunk/PIC/Torbens/main.c
ViewVC logotype

Annotation of /trunk/PIC/Torbens/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 101 - (hide annotations) (download)
Fri May 25 14:20:54 2007 UTC (17 years, 1 month ago) by torben
File MIME type: text/plain
File size: 1696 byte(s)
Trying to implement this !"#€%&/()= LCD module
1 torben 77
2     #include <pic18.h>
3     #include <stdio.h>
4 torben 101
5 torben 77 #include "delay.h"
6     #include "myi2c.h"
7     #include "barcode.h"
8     #include "globals.h"
9     #include "keyboard.h"
10    
11 torben 101
12    
13     #define USE_EXTERNAL_LCD
14    
15     #ifdef USE_EXTERNAL_LCD
16     #include "mylcd.h"
17     #else
18     #include "lcd.h"
19     #endif
20    
21    
22 torben 77 /*
23     void i2c_init(void)
24     {
25     // I2C_MODULE hører hjemme i i2c.h
26     #ifdef I2C_MODULE
27     SSPMode(MASTER_MODE);
28     SSPEN = 1; //Synch. Serial Port Enable
29     CKP = 1; //SCL Release control bit
30    
31     //note to self : husk altid at justere Baud-rate generatoren så at det passer sammen med krystal-frekvensen
32     SSPADD = 0x0A;
33     #else
34     SCL_DIR = I2C_OUTPUT;
35     SDA_DIR = I2C_OUTPUT;
36     SDA = 0;
37     SCL = 0;
38     #endif
39     }
40     */
41    
42    
43 torben 101
44    
45    
46 torben 77 void main(void)
47     {
48     char key, key2;
49     char buffer[5];
50     int i;
51 torben 101 char x = 0;
52     char y = 'A';
53     TRISB0= 0;
54    
55 torben 77 InitI2C();
56     barcode_init();
57    
58 torben 101 #ifdef USE_EXTERNAL_LCD
59     mylcd_init();
60     #else
61     lcd_init(0);
62     #endif
63    
64    
65    
66 torben 77 while (1)
67     {/*
68     if (barcode_is_ready())
69     {
70     lcd_home();
71     for (i=0; i<20; i++)
72     {
73     if (i<barcode_get_length())
74     lcd_putch(global_barcode_buffer[i]);
75     else
76     lcd_putch(' ');
77     }
78     barcode_reset();
79     }
80    
81     key = keyboard_read();
82    
83    
84     lcd_goto(0x40);
85    
86     if (key ==0)
87     lcd_puts(" ");
88     else
89     {
90     key2 = key;
91     for (i=0;i<8;i++)
92     {
93     if (key & 0x80)
94     lcd_putch('1');
95     else
96     lcd_putch('0');
97     key <<= 1;
98     }
99     lcd_putch('_');
100     lcd_putch(key2);
101     }
102     */
103    
104     key = keyboard_read_safe();
105 torben 101 key = 'a'; //debug
106 torben 77 if (key)
107 torben 101 {
108     #ifdef USE_EXTERNAL_LCD
109     mylcd_putch(key);
110     #else
111 torben 77 lcd_putch(key);
112 torben 101 #endif
113     }
114    
115 torben 77
116     DelayMs(30);
117 torben 101
118     x++;
119     RB0 = x;
120    
121    
122 torben 77 }
123     }
124 torben 101

  ViewVC Help
Powered by ViewVC 1.1.20