Forum: Mikrocontroller und Digitale Elektronik DOGXL160-7 with MSP430G2452 through I2C


von toann (Gast)


Lesenswert?

Hello,
I'm currently working on program for displaying numbers on graphical LCD 
display DOGXL160-7 through I2C bus with MSP430G2452 microcontroller. I 
managed to get I2C bus working (I am able to set all pixels on display 
or reset it) but I can't display anything specific :( Can you please 
give me some advice?
1
#include "display.h"
2
#include"usi_i2c.h"
3
#include<stdint.h>
4
#include <msp430.h>
5
6
const unsigned char fonts[] = { /* USCI Font Table 7x5 Font Size */0x00, 0x00,
7
    0x00, 0x00, 0x00, /* Each Row describes a 7x5 Font */
8
    0x00, 0x00, 0x00, 0x00, 0x00, /* Each element in a row describes 7 (8) Column Pixels */
9
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00,
15
    0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0x00,
16
    0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x00,
17
    0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00,
18
    0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, 0x0E, 0xFC, 0x40, 0x38,
19
    0xC0, 0xCC, 0x12, 0x12, 0x12, 0xC0, 0xDE, 0x14, 0x14, 0x10, 0x20, 0x30,
20
    0x38, 0x30, 0x20, 0x00, 0x7C, 0x38, 0x10, 0x00, 0x00, 0x10, 0x38, 0x7C,
21
    0x00, 0x08, 0x18, 0x38, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22
    0x00, 0xF2, 0x00, 0x00, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0x28, 0xFE, 0x28,
23
    0xFE, 0x28, 0x24, 0x54, 0xFE, 0x54, 0x48, 0xC4, 0xC8, 0x10, 0x26, 0x46,
24
    0x6C, 0x92, 0xAA, 0x44, 0x0A, 0x00, 0xA0, 0xC0, 0x00, 0x00, 0x00, 0x38,
25
    0x44, 0x82, 0x00, 0x00, 0x82, 0x44, 0x38, 0x00, 0x28, 0x10, 0x7C, 0x10,
26
    0x28, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x0A, 0x0C, 0x00, 0x00, 0x10,
27
    0x10, 0x10, 0x10, 0x10, 0x00, 0x06, 0x06, 0x00, 0x00, 0x04, 0x08, 0x10,
28
    0x20, 0x40, 0x7C, 0x8A, 0x92, 0xA2, 0x7C, 0x00, 0x42, 0xFE, 0x02, 0x00,
29
    0x42, 0x86, 0x8A, 0x92, 0x62, 0x84, 0x82, 0xA2, 0xD2, 0x8C, 0x18, 0x28,
30
    0x48, 0xFE, 0x08, 0xE4, 0xA2, 0xA2, 0xA2, 0x9C, 0x3C, 0x52, 0x92, 0x92,
31
    0x0C, 0x80, 0x8E, 0x90, 0xA0, 0xC0, 0x6C, 0x92, 0x92, 0x92, 0x6C, 0x60,
32
    0x92, 0x92, 0x94, 0x78, 0x00, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x6A, 0x6C,
33
    0x00, 0x00, 0x10, 0x28, 0x44, 0x82, 0x00, 0x28, 0x28, 0x28, 0x28, 0x28,
34
    0x00, 0x82, 0x44, 0x28, 0x10, 0x40, 0x80, 0x8A, 0x90, 0x60, 0x4C, 0x92,
35
    0x9E, 0x82, 0x7C, 0x7E, 0x88, 0x88, 0x88, 0x7E, 0xFE, 0x92, 0x92, 0x92,
36
    0x6C, 0x7C, 0x82, 0x82, 0x82, 0x44, 0xFE, 0x82, 0x82, 0x44, 0x38, 0xFE,
37
    0x92, 0x92, 0x92, 0x82, 0xFE, 0x90, 0x90, 0x90, 0x80, 0x7C, 0x82, 0x92,
38
    0x92, 0x5E, 0xFE, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x82, 0xFE, 0x82, 0x00,
39
    0x04, 0x02, 0x82, 0xFC, 0x80, 0xFE, 0x10, 0x28, 0x44, 0x82, 0xFE, 0x02,
40
    0x02, 0x02, 0x02, 0xFE, 0x40, 0x30, 0x40, 0xFE, 0xFE, 0x20, 0x10, 0x08,
41
    0xFE, 0x7C, 0x82, 0x82, 0x82, 0x7C, 0xFE, 0x90, 0x90, 0x90, 0x60, 0x7C,
42
    0x82, 0x8A, 0x84, 0x7A, 0xFE, 0x90, 0x98, 0x94, 0x62, 0x62, 0x92, 0x92,
43
    0x92, 0x8C, 0x80, 0x80, 0xFE, 0x80, 0x80, 0xFC, 0x02, 0x02, 0x02, 0xFC,
44
    0xF8, 0x04, 0x02, 0x04, 0xF8, 0xFC, 0x02, 0x1C, 0x02, 0xFC, 0xC6, 0x28,
45
    0x10, 0x28, 0xC6, 0xE0, 0x10, 0x0E, 0x10, 0xE0, 0x86, 0x8A, 0x92, 0xA2,
46
    0xC2, 0x00, 0xFE, 0x82, 0x82, 0x00, 0xA8, 0x68, 0x3E, 0x68, 0xA8, 0x00,
47
    0x82, 0x82, 0xFE, 0x00, 0x20, 0x40, 0x80, 0x40, 0x20, 0x02, 0x02, 0x02,
48
    0x02, 0x02, 0x00, 0x80, 0x40, 0x20, 0x00, 0x04, 0x2A, 0x2A, 0x2A, 0x1E,
49
    0xFE, 0x0A, 0x12, 0x12, 0x0C, 0x1C, 0x22, 0x22, 0x22, 0x04, 0x0C, 0x12,
50
    0x12, 0x0A, 0xFE, 0x1C, 0x2A, 0x2A, 0x2A, 0x18, 0x10, 0x7E, 0x90, 0x80,
51
    0x40, 0x30, 0x4A, 0x4A, 0x4A, 0x7C, 0xFE, 0x10, 0x20, 0x20, 0x1E, 0x00,
52
    0x00, 0x5E, 0x00, 0x00, 0x04, 0x02, 0x22, 0xBC, 0x00, 0xFE, 0x08, 0x14,
53
    0x22, 0x00, 0x00, 0x82, 0xFE, 0x02, 0x00, 0x3E, 0x20, 0x18, 0x20, 0x1E,
54
    0x3E, 0x10, 0x20, 0x20, 0x1E, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x3E, 0x28,
55
    0x28, 0x28, 0x10, 0x10, 0x28, 0x28, 0x18, 0x3E, 0x3E, 0x10, 0x20, 0x20,
56
    0x10, 0x12, 0x2A, 0x2A, 0x2A, 0x04, 0x20, 0xFC, 0x22, 0x02, 0x04, 0x3C,
57
    0x02, 0x02, 0x04, 0x3E, 0x38, 0x04, 0x02, 0x04, 0x38, 0x3C, 0x02, 0x0C,
58
    0x02, 0x3C, 0x22, 0x14, 0x08, 0x14, 0x22, 0x30, 0x0A, 0x0A, 0x0A, 0x3C,
59
    0x22, 0x26, 0x2A, 0x32, 0x22, 0x00, 0x10, 0x6C, 0x82, 0x00, 0x00, 0x00,
60
    0xFE, 0x00, 0x00, 0x00, 0x82, 0x6C, 0x10, 0x00, 0x10, 0x10, 0x54, 0x38,
61
    0x10, 0x10, 0x38, 0x54, 0x10, 0x10, 0x0E, 0x94, 0x24, 0x94, 0x0E, 0x0E,
62
    0x14, 0xA4, 0x14, 0x0E, 0x0E, 0x54, 0xA4, 0x54, 0x0E, 0x04, 0x2A, 0x6A,
63
    0xAA, 0x1E, 0x04, 0x2A, 0xAA, 0x2A, 0x1E, 0xFE, 0xFE, 0x92, 0x92, 0x92,
64
    0xBC, 0x42, 0x42, 0x42, 0xBC, 0x0C, 0x52, 0x12, 0x52, 0x0C, 0x3A, 0x4C,
65
    0x54, 0x64, 0xB8, 0x18, 0x26, 0x3C, 0x64, 0x18, 0xBC, 0x02, 0x02, 0x02,
66
    0xBC, 0x1C, 0x42, 0x02, 0x44, 0x1E, 0x40, 0x20, 0x10, 0x08, 0x04, 0x2A,
67
    0x2C, 0x38, 0x68, 0xA8, 0x30, 0x40, 0x30, 0x08, 0x30, 0x52, 0xAA, 0xAA,
68
    0xAA, 0x94, 0x7E, 0x90, 0xFE, 0x90, 0x90, 0x2C, 0x2A, 0x1C, 0x2A, 0x1A,
69
    0x12, 0x7E, 0x92, 0x92, 0x42, 0xFE, 0xA0, 0xA8, 0x5E, 0x0A, 0x38, 0x7C,
70
    0x7C, 0x7C, 0x38, 0x38, 0x44, 0x44, 0x44, 0x38, 0x10, 0x38, 0x7C, 0x38,
71
    0x10, 0x10, 0x28, 0x44, 0x28, 0x10, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x70,
72
    0x8A, 0x8C, 0x88, 0x88, 0x06, 0x0A, 0x12, 0x22, 0x7E, 0x02, 0x22, 0x52,
73
    0x8A, 0x02, 0x02, 0x8A, 0x52, 0x22, 0x02, 0x08, 0x1C, 0x2A, 0x08, 0xF8,
74
    0x20, 0x40, 0xFE, 0x40, 0x20, 0x08, 0x04, 0xFE, 0x04, 0x08, 0x00, 0x00,
75
    0x00, 0x00, 0x00, 0x0E, 0x0A, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x80,
76
    0x80, 0x02, 0x02, 0x1E, 0x00, 0x00, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00,
77
    0x18, 0x18, 0x00, 0x00, 0x50, 0x50, 0x52, 0x54, 0x78, 0x20, 0x22, 0x2C,
78
    0x28, 0x30, 0x04, 0x08, 0x1E, 0x20, 0x00, 0x18, 0x10, 0x32, 0x12, 0x1C,
79
    0x12, 0x12, 0x1E, 0x12, 0x12, 0x12, 0x14, 0x18, 0x3E, 0x10, 0x10, 0x3E,
80
    0x10, 0x14, 0x18, 0x02, 0x12, 0x12, 0x1E, 0x02, 0x2A, 0x2A, 0x2A, 0x3E,
81
    0x00, 0x18, 0x00, 0x1A, 0x02, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x80,
82
    0x82, 0xBC, 0x90, 0xE0, 0x08, 0x10, 0x3E, 0x40, 0x80, 0x70, 0x40, 0xC2,
83
    0x44, 0x78, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x44, 0x48, 0x50, 0xFE, 0x40,
84
    0x42, 0xFC, 0x40, 0x42, 0x7C, 0x50, 0x50, 0xFE, 0x50, 0x50, 0x10, 0x62,
85
    0x42, 0x44, 0x78, 0x20, 0xC0, 0x42, 0x7C, 0x40, 0x42, 0x42, 0x42, 0x42,
86
    0x7E, 0x40, 0xF2, 0x44, 0xF8, 0x40, 0x52, 0x52, 0x02, 0x04, 0x38, 0x42,
87
    0x44, 0x48, 0x54, 0x62, 0x40, 0xFC, 0x42, 0x52, 0x62, 0x60, 0x12, 0x02,
88
    0x04, 0x78, 0x10, 0x62, 0x52, 0x4C, 0x78, 0x50, 0x52, 0x7C, 0x90, 0x10,
89
    0x70, 0x00, 0x72, 0x04, 0x78, 0x20, 0xA2, 0xBC, 0xA0, 0x20, 0x00, 0xFE,
90
    0x10, 0x08, 0x00, 0x22, 0x24, 0xF8, 0x20, 0x20, 0x02, 0x42, 0x42, 0x42,
91
    0x02, 0x42, 0x54, 0x48, 0x54, 0x60, 0x44, 0x48, 0xDE, 0x68, 0x44, 0x00,
92
    0x02, 0x04, 0xF8, 0x00, 0x1E, 0x00, 0x40, 0x20, 0x1E, 0xFC, 0x22, 0x22,
93
    0x22, 0x22, 0x40, 0x42, 0x42, 0x44, 0x78, 0x20, 0x40, 0x20, 0x10, 0x0C,
94
    0x4C, 0x40, 0xFE, 0x40, 0x4C, 0x40, 0x48, 0x44, 0x4A, 0x70, 0x00, 0x54,
95
    0x54, 0x54, 0x02, 0x1C, 0x24, 0x44, 0x04, 0x0E, 0x02, 0x14, 0x08, 0x14,
96
    0x60, 0x50, 0x7C, 0x52, 0x52, 0x52, 0x20, 0xFE, 0x20, 0x28, 0x30, 0x02,
97
    0x42, 0x42, 0x7E, 0x02, 0x52, 0x52, 0x52, 0x52, 0x7E, 0x20, 0xA0, 0xA2,
98
    0xA4, 0x38, 0xF0, 0x02, 0x04, 0xF8, 0x00, 0x3E, 0x00, 0x7E, 0x02, 0x0C,
99
    0x7E, 0x02, 0x04, 0x08, 0x10, 0x7E, 0x42, 0x42, 0x42, 0x7E, 0x70, 0x40,
100
    0x42, 0x44, 0x78, 0x42, 0x42, 0x02, 0x04, 0x18, 0x40, 0x20, 0x80, 0x40,
101
    0x00, 0xE0, 0xA0, 0xE0, 0x00, 0x00, 0x1C, 0x22, 0x12, 0x0C, 0x32, 0x04,
102
    0xAA, 0x2A, 0xAA, 0x1E, 0x3E, 0x54, 0x54, 0x54, 0x28, 0x14, 0x2A, 0x2A,
103
    0x22, 0x04, 0x7E, 0x08, 0x08, 0x10, 0x78, 0x1C, 0x22, 0x32, 0x2A, 0x24,
104
    0x1E, 0x28, 0x48, 0x48, 0x30, 0x10, 0x2A, 0x2A, 0x2A, 0x3C, 0x04, 0x02,
105
    0x3C, 0x20, 0x20, 0x40, 0x40, 0x00, 0xE0, 0x00, 0x04, 0x02, 0x22, 0xBC,
106
    0x00, 0xA0, 0x40, 0xA0, 0x00, 0x00, 0x18, 0x24, 0x7E, 0x24, 0x08, 0x28,
107
    0xFE, 0x2A, 0x02, 0x02, 0x3E, 0x90, 0xA0, 0xA0, 0x1E, 0x1C, 0xA2, 0x22,
108
    0xA2, 0x1C, 0x7E, 0x28, 0x48, 0x48, 0x30, 0x30, 0x48, 0x48, 0x28, 0x7E,
109
    0x3C, 0x52, 0x52, 0x52, 0x3C, 0x0C, 0x14, 0x08, 0x14, 0x18, 0x1A, 0x26,
110
    0x20, 0x26, 0x1A, 0x3C, 0x82, 0x02, 0x84, 0x3E, 0xC6, 0xAA, 0x92, 0x82,
111
    0x82, 0x22, 0x3C, 0x20, 0x3E, 0x22, 0xA2, 0x94, 0x88, 0x94, 0xA2, 0x30,
112
    0x0A, 0x0A, 0x0A, 0x3C, 0x28, 0x28, 0x3E, 0x28, 0x48, 0x22, 0x3C, 0x28,
113
    0x28, 0x2E, 0x3E, 0x28, 0x38, 0x28, 0x3E, 0x10, 0x10, 0x54, 0x10, 0x10,
114
    0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE };
115
116
uint16_t lcdInitMacro[] = { // DogXL160 Initialization Commands
117
    0x78, setComEndH, setComEndL, setLCDMappingControl, setScrollLineLSB,
118
        setScrollLineMSB, setPanelLoading, setLCDBiasRatio,
119
        setVbiasPotentiometerH, setVbiasPotentiometerL,
120
        setRAMAddressControl, setDisplayEnable };
121
122
volatile uint16_t table[] = { 0x78 };
123
volatile int amount = 1;
124
125
void clearLCD(unsigned char *buffer);
126
void initLCD(unsigned char *buffer);
127
void allPixelsOnLCD(unsigned char *buffer);
128
void resetLCD(unsigned char *buffer);
129
void writeLCD(unsigned char row, unsigned char col, unsigned short f,
130
    unsigned char *buffer);
131
void writeStringLCD(unsigned char y, unsigned char x, char word[],
132
    unsigned char *buffer);
133
void sendDataLCD(uint16_t* SData, unsigned short i, unsigned char *buffer);
134
void setPageAddressLCD(unsigned char PA, unsigned char *buffer);
135
void setColumnAdressLCD(unsigned char CA, unsigned char *buffer);
136
137
/*
138
 * Function for initiating LCD
139
 * init - pointer to void that contains the initialized value
140
 */
141
void initLCD(unsigned char *buffer) {
142
  sendDataLCD(lcdInitMacro, 12, buffer);
143
}
144
145
/*
146
 * Function for sending data to LCD through I2C
147
 * unsigned char* SData-pointer to the Data to be written to the LCD
148
 * uint i-number of the  Datas  to be written to the LCD
149
 */
150
void sendDataLCD(uint16_t* SData, unsigned short i, unsigned char *buffer) {
151
  i2c_send_sequence(SData, i, buffer, LPM0_BITS); //ok
152
}
153
154
/*
155
 * Function for setting page address
156
 * unsigned char PA-page Address of the LCD RAM memory to be written
157
 */
158
void setPageAddressLCD(unsigned char PA, unsigned char *buffer) {
159
  // static unsigned char const*suma=PA+pageAddress;
160
  //static const unsigned char sum=PA+pageAddress;
161
162
  //sum = (uint16_t) (PA + pageAddress);
163
  uint16_t command[] = { pageAddress };
164
  command[0] += PA;
165
  // uint16_t Cmd[]={PA+pageAddress};                                               //ok
166
  // uint16_t Cmd={(uint16_t)(PA+pageAddress)};
167
  //&Cmd[0]=sum; //PA+pageAddress ; Page Address Command = Page Address Initial Command + Page Address
168
  sendDataLCD(command, 1, buffer);
169
}
170
171
/*
172
 * Function for setting column address of LCD RAM memory
173
 * unsigned char CA-column Address of the LCD RAM memory to be written
174
 */
175
void setColumnAdressLCD(unsigned char CA, unsigned char *buffer) {
176
  unsigned char H = 0x00, L = 0x00;
177
  uint16_t columnAddress[] = { 0x78, columnLSB0, columnMSB0 };
178
  L = (CA & 0x0F); //separate Command Address to low and high
179
  H = (CA & 0xF0);
180
  H = (H >> 4);
181
  columnAddress[1] = (columnLSB0 + L); //column address CommandLSB = Column Address Initial Command
182
                     //+column address bits 0..3
183
  columnAddress[2] = (columnMSB0 + H); //column address CommandMSB = Column Address Initial Command
184
                     //+column address bits 4..7
185
  sendDataLCD(columnAddress, 3, buffer);
186
}
187
188
/*
189
 * Function for setting all pixels on
190
 */
191
void allPixelsOnLCD(unsigned char *buffer) {
192
  uint16_t Cmd[] = { 0x78, setAllPixelsOn };
193
  sendDataLCD(Cmd, 2, buffer);
194
}
195
196
/*
197
 * Function for resetting system
198
 */
199
void resetLCD(unsigned char *buffer) {
200
  uint16_t Cmd[] = { 0x78, systemReset };
201
  sendDataLCD(Cmd, 2, buffer);
202
}
203
204
/*
205
 * Function for setting all pixels off
206
 */
207
void clearLCD(unsigned char *buffer) {
208
  uint16_t lcdData[] = { 0x78, 0x00 };
209
  unsigned char p = 0, c;
210
  for (p = 26; p > 0; p--) { //25 pages
211
    for (c = 160; c > 0; c--) { //160 columns
212
      setPageAddressLCD(0x00 + p, buffer);
213
      setColumnAdressLCD(0x00 + c, buffer);
214
      sendDataLCD(lcdData, 2, buffer);
215
    }
216
  }
217
}
218
219
/*
220
 * Function for writing fonts from array to LCD
221
 *
222
 * unsigned char row-page Address
223
 * unsigned char col-column Address
224
 * unsigned short f-pointer to the font to be written to the LCD
225
 */
226
void writeLCD(unsigned char row, unsigned char col, unsigned short f,
227
    unsigned char *buffer) { //each font consists of 5 columns of 2 pages
228
  //each page presents 4 pixels
229
  uint16_t lcdData[3]; //pointer to the both pages of a column
230
  uint16_t* ptr;
231
  unsigned char H = 0x00, L = 0x00, c;
232
  for (c = 0; c < 5; c++) { //font block size 5 columns
233
    L = (fonts[f + c] & 0x0F); //LSB 4 pixels are saved to L
234
    H = (fonts[f + c] & 0xF0); //MSB 4 pixels are saved to H
235
    H = (H >> 4);
236
    lcdData[1] = 0x00;
237
    lcdData[2] = 0x00;
238
    if ((H & 0x01) == 0x01) { //each pixel in the H is converted to 2 bits, 11 pixel on - 00 pixel off
239
      lcdData[1] = lcdData[1] + 0xC0;
240
    };
241
    if ((H & 0x02) == 0x02) {
242
      lcdData[1] = lcdData[1] + 0x30;
243
    };
244
    if ((H & 0x04) == 0x04) {
245
      lcdData[1] = lcdData[1] + 0x0C;
246
    };
247
    if ((H & 0x08) == 0x08) {
248
      lcdData[1] = lcdData[1] + 0x03;
249
    };
250
    if ((L & 0x01) == 0x01) { //each pixel in the L is converted to 2 bits,  11 pixel on - 00 pixel off
251
      lcdData[2] = lcdData[2] + 0xC0;
252
    };
253
    if ((L & 0x02) == 0x02) {
254
      lcdData[2] = lcdData[2] + 0x30;
255
    };
256
    if ((L & 0x04) == 0x04) {
257
      lcdData[2] = lcdData[2] + 0x0C;
258
    };
259
    if ((L & 0x08) == 0x08) {
260
      lcdData[2] = lcdData[2] + 0x03;
261
    };
262
    unsigned char p;
263
    uint16_t probne[] = { 0x78, 0x10, 0x14, 0x18, 0x02 };
264
    for (p = 0; p < 2; p++) { //font page size 2 pages
265
      ptr = lcdData + p;
266
      setPageAddressLCD(0x00 + p + row, buffer);
267
      setColumnAdressLCD(0x00 + c + col, buffer);
268
      sendDataLCD(ptr, 1, buffer); //column that consists of two pages is sent to the LCD
269
    }
270
  }
271
}
272
273
/*
274
 * Function for writing String to LCD
275
 *
276
 * unsigned char y-page address
277
 * unsigned char x-column address
278
 * char world[]-pointer to the String to be written to the LCD
279
 */
280
void writeStringLCD(unsigned char y, unsigned char x, char word[],
281
    unsigned char *buffer) {
282
  unsigned char k, a = 0;
283
  do { //writes a font to a block of 8x5 Pixels
284
    k = word[a];
285
    writeLCD(y, x, 5 * k, buffer);
286
    x = x + 6; //points to the next Block
287
    a++;
288
    k = word[a];
289
  } while (k != 0); //writes until the end of the String
290
}

Best regards,
Kasia

: Verschoben durch User
von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Although lots of the participants here are well abled to communicate in 
english, german is the preferred language used in this forum.

You might have better chances in this forum's english sibling on 
embdev.net

Besides that, some generic rules:

Source code, that is longer than say, a hundred lines, should not be 
embedded in the posting but added as an attachment.

Describe your problem. Describe what specific steps you've undertaken 
and what precisely does not work.

von u8g2 (Gast)


Lesenswert?

The code does not switch to data mode (at least not in the visible part 
of the code): Data has to be transfered to a different I2C slave 
address, see the UC1610 datasheet.

Oliver

von toann (Gast)


Lesenswert?

Thank you, Rufus, I've posted thread on the forum you mentioned. My 
german skills are poor (I usually understand what I'm reading - that's 
how I got here - but I struggle with writing), can I stay here or by 
"german is the preferred language" you meant there're no other languages 
allowed?

You were right, Oliver, thank you! Now I am able to draw lines. 
Displaying text still doesn't work though.

Best regards,
Kasia

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

toann schrieb:
> can I stay here

Of course.

> or by "german is the preferred language" you meant
> there're no other languages allowed?

Though we germans invented the word "verboten" that's not the case here.

Chances for useful replies are just greater when you use the common 
language - and that is german.


But, as you've already noticed, you've already gotten a useful reply, 
from someone who's quite adept at using LC displays and displaying text 
on them.


> Displaying text still doesn't work though.

Again, it would be more helpful if you describe what doesn't work. Do 
you receive garbled pixels on your Display? Do you see nothing?

von toann (Gast)


Lesenswert?

When I use writeStringLCD function to display text, I receive garbled 
pixels. I am able to display some text directly through I2C, for example 
for displaying "cat" I send:
uint16_t 
cat[]={0x7A,0x3c,0xc3,0xc3,0x00,0xfc,0x33,0x33,0xfc,0x03,0x03,0xff,0x03, 
0x03,0x00,0x00};
i2c_send_sequence(cat,16, &status, LPM0_BITS);
and it works, I cant see "cat" but it's the only way it works. (0x7A is 
write data command, the rest is "cat").
I also have some problems with returning to specific position, for 
example top left corner of the display, it just doesn't go there. It 
causes crossing the display ranges.

von toann (Gast)


Lesenswert?

*I CAN see "cat", not "cant", excuse me.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.