SHOW:
|
|
- or go back to the newest paste.
1 | #include<msp430x14x.h> | |
2 | #include "lcd.h" | |
3 | #include "portyLcd.h" | |
4 | ||
5 | unsigned char i; | |
6 | unsigned char znak; | |
7 | ||
8 | int adres; | |
9 | float pole; | |
10 | int linia; | |
11 | int poziom; | |
12 | int ink1; | |
13 | int ink2; | |
14 | int granica; | |
15 | int linia_paletki; | |
16 | ||
17 | void polozenie_paletki(int a) { | |
18 | if (a) { | |
19 | if (granica >= 0) | |
20 | granica--; | |
21 | } | |
22 | else { | |
23 | if (granica <= 9) | |
24 | granica++; | |
25 | } | |
26 | } | |
27 | ||
28 | ||
29 | void paletka() { | |
30 | ||
31 | SEND_CMD(CG_RAM_ADDR + 1); | |
32 | int x; | |
33 | int a = granica; | |
34 | if (a >= 5) { | |
35 | a = granica - 5; | |
36 | ||
37 | } | |
38 | ||
39 | for (x = 0;x<8;x++) { | |
40 | if (a <= x&&a + 4>x) | |
41 | SEND_CHAR(16); | |
42 | else | |
43 | SEND_CHAR(0); | |
44 | } | |
45 | if (granica<5) | |
46 | SEND_CMD(DD_RAM_ADDR); | |
47 | else | |
48 | SEND_CMD(DD_RAM_ADDR + 40); | |
49 | SEND_CHAR(1); | |
50 | } | |
51 | void pilka(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int addr) { | |
52 | int znaczek[8] = { a1,a2,a3,a4,a5,a6,a7,a8 }; | |
53 | SEND_CMD(CG_RAM_ADDR); | |
54 | int x; | |
55 | for (x = 0;x<8;x++) | |
56 | SEND_CHAR(znaczek[x]); | |
57 | SEND_CMD(DD_RAM_ADDR + addr); | |
58 | SEND_CHAR(0); | |
59 | } | |
60 | ||
61 | void increment() { | |
62 | if (adres == 15 || adres == 55) | |
63 | ink1 = 1; | |
64 | if (adres == 0 || adres == 40) | |
65 | ink1 = 0; | |
66 | ||
67 | if (ink1 == 0 && pole == 1) | |
68 | adres++; | |
69 | if (ink1 == 1 && pole == 16) | |
70 | adres--; | |
71 | ||
72 | if (ink1 == 0) | |
73 | pole = pole / 2; | |
74 | ||
75 | if (ink1 == 1) | |
76 | pole = pole * 2; | |
77 | ||
78 | if (ink1 == 0 && pole == 1) | |
79 | pole = 16; | |
80 | if (ink1 == 1 && pole == 16) | |
81 | pole = 1; | |
82 | if (linia == 2 && adres <= 15) | |
83 | adres = adres + 40; | |
84 | if (linia == 1 && adres >= 40) | |
85 | adres = adres - 40; | |
86 | } | |
87 | void cross() { | |
88 | if (poziom == 7 && linia == 2) | |
89 | ink2 = 1; | |
90 | ||
91 | if (poziom == 0 && linia == 1) | |
92 | ink2 = 0; | |
93 | ||
94 | ||
95 | if (ink2 == 0 && poziom == 7 && linia == 1) { | |
96 | ||
97 | linia = 2; | |
98 | poziom = 0; | |
99 | } | |
100 | if (ink2 == 1 && poziom == 0 && linia == 2) { | |
101 | ||
102 | linia = 1; | |
103 | poziom = 7; | |
104 | } | |
105 | if (ink2) | |
106 | poziom--; | |
107 | else | |
108 | poziom++; | |
109 | } | |
110 | ||
111 | ||
112 | void wyswietl_pilke() { | |
113 | ||
114 | if (poziom == 0) | |
115 | pilka(pole, 0, 0, 0, 0, 0, 0, 0, adres) | |
116 | if (poziom == 1) | |
117 | pilka(0, pole, 0, 0, 0, 0, 0, 0, adres) | |
118 | if (poziom == 2) | |
119 | pilka(0, 0, pole, 0, 0, 0, 0, 0, adres) | |
120 | if (poziom == 3) | |
121 | pilka(0, 0, 0, pole, 0, 0, 0, 0, adres) | |
122 | if (poziom == 4) | |
123 | pilka(0, 0, 0, 0, pole, 0, 0, 0, adres) | |
124 | if (poziom == 5) | |
125 | pilka(0, 0, 0, 0, 0, pole, 0, 0, adres) | |
126 | if (poziom == 6) | |
127 | pilka(0, 0, 0, 0, 0, 0, pole, 0, adres) | |
128 | if (poziom == 7) | |
129 | pilka(0, 0, 0, 0, 0, 0, 0, pole, adres) | |
130 | ||
131 | ||
132 | ||
133 | ||
134 | } | |
135 | ||
136 | void main(void) | |
137 | { | |
138 | // STATUS LED | |
139 | WDTCTL = WDTPW + WDTHOLD; // zatrzymanie WDT | |
140 | float a, b;int y; | |
141 | InitPortsLcd(); // inicjalizacja portów | |
142 | InitLCD(); // inicjalizacja LCD | |
143 | clearDisplay(); // czyszczenie LCD | |
144 | linia = 1; | |
145 | adres = 0; | |
146 | pole = 0; | |
147 | poziom = 0; | |
148 | while (1) // nieskończona pętla | |
149 | { | |
150 | ||
151 | ||
152 | ||
153 | ||
154 | ||
155 | ||
156 | ||
157 | } |