Собери свою радиосхему!
Суббота, 25.11.2017, 12:29 Приветствую Вас Гость

cxema21.ucoz.ru

Главная | Регистрация | Вход | RSS

Пример кода для Nokia 5110 (3310) без библиотек - Форум

[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
Страница 1 из 11
Модератор форума: Advanced 
Форум » Микроконтроллеры » Микроконтроллеры AVR » Пример кода для Nokia 5110 (3310) без библиотек
Пример кода для Nokia 5110 (3310) без библиотек
АдванседДата: Пятница, 19.09.2014, 19:05 | Сообщение # 1
Сержант
Группа: Администраторы
Сообщений: 35
Репутация: 0
Статус: Offline
Пример кода без использования библиотек для дисплеев 5510-3310

Цитата
#define PIN_SCE   7
#define PIN_RESET 6
#define PIN_DC    5
#define PIN_SDIN  4
#define PIN_SCLK  3
#define PIN_LED   8

#define LCD_C     LOW
#define LCD_D     HIGH

static const byte font[] =
{0x00,0x00,0x00,0x00,0x00,0x2E,0x00,0x00,0x06,0x00,0x06,0x00,0x3E,0x14,0x3E,0x00,0x2E,0x6B,0x3A,
0x00,0x32,0x08,0x26,0x00,0x14,0x2A,0x34,0x00,0x00,0x06,0x00,0x00,0x00,0x1C,0x22,0x00,0x22,0x1C,
0x00,0x00,0x14,0x0E,0x14,0x00,0x08,0x1C,0x08,0x00,0x40,0x20,0x00,0x00,0x08,0x08,0x08,0x00,0x08,
0x08,0x00,0x00,0x30,0x0C,0x02,0x00,0x3F,0x21,0x3F,0x00,0x22,0x3F,0x20,0x00,0x3D,0x25,0x27,0x00,
0x21,0x25,0x3F,0x00,0x07,0x04,0x3F,0x00,0x27,0x25,0x3D,0x00,0x3F,0x25,0x3D,0x00,0x01,0x01,0x3F,
0x00,0x3F,0x25,0x3F,0x00,0x27,0x25,0x3F,0x00,0x00,0x22,0x00,0x00,0x40,0x22,0x00,0x00,0x08,0x14,
0x22,0x00,0x14,0x14,0x14,0x00,0x22,0x14,0x08,0x00,0x02,0x2A,0x0E,0x00,0x1C,0x22,0x2C,0x00,0x3F,
0x05,0x3F,0x00,0x3F,0x25,0x3B,0x00,0x3F,0x21,0x21,0x00,0x3F,0x21,0x3E,0x00,0x3F,0x25,0x21,0x00,
0x3F,0x05,0x01,0x00,0x3F,0x21,0x3D,0x00,0x3F,0x04,0x3F,0x00,0x21,0x3F,0x21,0x00,0x20,0x21,0x1F,
0x00,0x3F,0x04,0x3B,0x00,0x3F,0x20,0x20,0x00,0x3F,0x06,0x3F,0x00,0x3F,0x18,0x3F,0x00,0x3F,0x21,
0x3F,0x00,0x3F,0x05,0x07,0x00,0x1E,0x21,0x3E,0x00,0x3F,0x05,0x3B,0x00,0x27,0x25,0x3D,0x00,0x01,
0x3F,0x01,0x00,0x1F,0x20,0x3F,0x00,0x07,0x38,0x07,0x00,0x3F,0x30,0x3F,0x00,0x3B,0x04,0x3B,0x00,
0x27,0x24,0x3F,0x00,0x39,0x25,0x23,0x00,0x00,0x3E,0x22,0x00,0x02,0x0C,0x30,0x00,0x22,0x3E,0x00,
0x00,0x04,0x02,0x04,0x00,0x20,0x20,0x20,0x00,0x02,0x04,0x00,0x00,0x10,0x2A,0x3C,0x00,0x3E,0x28,
0x10,0x00,0x1C,0x22,0x22,0x00,0x10,0x28,0x3E,0x00,0x1C,0x2A,0x2C,0x00,0x08,0x3C,0x0A,0x00,0x08,
0x54,0x38,0x00,0x3E,0x08,0x30,0x00,0x00,0x3A,0x00,0x00,0x40,0x3A,0x00,0x00,0x3E,0x10,0x28,0x00,
0x22,0x3E,0x20,0x00,0x3E,0x0C,0x3E,0x00,0x3E,0x02,0x3C,0x00,0x1C,0x22,0x1C,0x00,0x7C,0x14,0x08,
0x00,0x08,0x14,0x7C,0x00,0x3E,0x04,0x02,0x00,0x24,0x2A,0x12,0x00,0x04,0x1E,0x24,0x00,0x1E,0x20,
0x3E,0x00,0x0E,0x30,0x0E,0x00,0x3E,0x30,0x3E,0x00,0x36,0x08,0x36,0x00,0x0C,0x50,0x3C,0x00,0x32,
0x2A,0x26,0x00,0x08,0x1C,0x22,0x00,0x00,0x3E,0x00,0x00,0x22,0x1C,0x08,0x00,0x08,0x04,0x08,0x04,
0x00,0x00,0x00,0x00};

void LcdCharacter(char character)
{
for (int index = 0; index < 4; index++){LcdWrite(LCD_D, font[(character-32)*4+index]);}
}

void LcdClear(void)
{
for (int index = 0; index < 504; index++){LcdWrite(LCD_D, 0);}
}

void LcdInitialise(void)
{
pinMode(PIN_SCE, OUTPUT);
pinMode(PIN_RESET, OUTPUT);
pinMode(PIN_DC, OUTPUT);
pinMode(PIN_SDIN, OUTPUT);
pinMode(PIN_SCLK, OUTPUT);
pinMode(PIN_LED, OUTPUT);
digitalWrite(PIN_RESET, LOW);
digitalWrite(PIN_RESET, HIGH);

LcdWrite(LCD_C, 0x20 );  // LCD Extended Commands. 22-vertical
LcdWrite(LCD_C, 0x04 );  // Set Temp coefficent. //0x04
LcdWrite(LCD_C, 0x0c );  // LCD in normal mode. 0x0C 0x0D-negative
LcdWrite(LCD_C, 0x80 );  //SET X
LcdWrite(LCD_C, 0x40 );  //SET Y
}

void LcdString(char *characters)
{
while (*characters){LcdCharacter(*characters++);}
}

void LcdWrite(byte dc, byte data)
{
digitalWrite(PIN_DC, dc);
digitalWrite(PIN_SCE, LOW);
shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
digitalWrite(PIN_SCE, HIGH);
}

void setup(void)
{
LcdInitialise();
LcdClear();
digitalWrite(PIN_LED, HIGH); //Подсветка
}

int i=0;

void loop(void)
{
LcdWrite(LCD_C, 0x80 );  //SET X
LcdWrite(LCD_C, 0x40 );  //SET Y

LcdCharacter(i/10000%10+48);
LcdCharacter(i/1000%10+48);
LcdCharacter(i/100%10+48);
LcdCharacter(i/10%10+48);
LcdCharacter(i%10+48);
LcdString(" Hello, World!");

LcdWrite(LCD_C, 0x80 );  //SET X
LcdWrite(LCD_C, 0x42 );  //SET Y

for(int n=0;n<10;n++){LcdCharacter(random(96)+32);}

delay(1000);
i++;
}
 
Форум » Микроконтроллеры » Микроконтроллеры AVR » Пример кода для Nokia 5110 (3310) без библиотек
Страница 1 из 11
Поиск:

Форма входа
Поиск
Наш опрос
Какой у вас оператор сотовой связи
Всего ответов: 178
Статистика

Не  получится по этой схеме столько выжать

Добрый день, подскажите пожалуйста, что нужно изменить в это...

Сыровато очень. Нельзя вот так вот просто взять и назвать ме...

Рейтинг@Mail.ru