Чт мар 21, 2013 10:37:41
Atmega8 писал(а):ILI9320_AVR - при компиляции много ошибок...
Вт мар 26, 2013 13:09:57
Вт мар 26, 2013 14:21:43
Чт мар 28, 2013 12:40:24
Пт мар 29, 2013 19:03:25
Пн апр 01, 2013 19:28:36
Ср апр 24, 2013 08:20:03
#include "stm8s.h"
#include "stm8s_gpio.h"
#include "stm8s_clk.h"
#define MAX_X 131
#define MAX_Y 160
#define CMD 0
#define DAT 1
/* SPFD54124 Инструкции (см даташит)*/
#define SWRESET (0x01)
#define SLPOUT (0x11)
#define NORON (0x13)
#define INVOFF (0x20)
#define DISPON (0x29)
#define CASET (0x2A)
#define RASET (0x2B)
#define RAMWR (0x2C)
#define MADCTL (0x36)
#define IDMOFF (0x38)
#define COLMOD (0x3A)
/* Формирование цвета */
#define RGB(r,g,b) (uint16_t)((r >> 3) |((g >> 2) << 5) |((b >> 3) << 11))
/* Основные цвета */
#define COL_BLACK RGB(0,0,0)
#define COL_WHITE RGB(255,255,255)
#define COL_RED RGB(255,0,0)
#define COL_BLUE RGB(0,0,255)
#define COL_GREEN RGB(0,255,0)
#define COL_YELLOW RGB(255,255,0)
#define COL_MAGENTA RGB(255,0,255)
#define COL_AQUA RGB(0,255,255)
#define COL_PURPLE RGB(160,32,240)
#define COL_REDPINK RGB(255,50,50)
#define COL_ORANGE RGB(255,165,0)
// управление ногами rst,cs,sda,clk
#define RST_SET GPIO_WriteHigh(GPIOC, GPIO_PIN_6);
#define RST_RESET GPIO_WriteLow(GPIOC, GPIO_PIN_6);
#define CS_SET GPIO_WriteHigh(GPIOC, GPIO_PIN_4);
#define CS_RESET GPIO_WriteLow(GPIOC, GPIO_PIN_4);
#define SDA_SET GPIO_WriteHigh(GPIOC, GPIO_PIN_2);
#define SDA_RESET GPIO_WriteLow(GPIOC, GPIO_PIN_2);
#define CLK_SET GPIO_WriteHigh(GPIOC, GPIO_PIN_5);
#define CLK_RESET GPIO_WriteLow(GPIOC, GPIO_PIN_5);
#define F_CPU 16000000 //Тактовая частота процессора (внутр RC).
// функции задержек
void _delay_ms(uint32_t ms)
{
uint32_t nCount;
nCount=(F_CPU/10000)*ms; // возвращает тактовоую частоту HCLK в Гц, делим на 10000 и всё множим на ms
for (; nCount!=0; nCount--)
{
//6 тактов функция повтора + 4 пустые такта
__asm ("nop");
__asm ("nop");
__asm ("nop");
__asm ("nop");// = 10 тактов
}
}
/*Хардварный ресет драйвера*/
void lcd_reset()
{
RST_SET;
CS_SET;
CLK_SET;
_delay_ms(1);
RST_RESET;
CS_RESET;
_delay_ms(20);
RST_SET;
_delay_ms(20);
}
void lcd_SendByte(char mode,unsigned char c)
{
CS_RESET;
CLK_RESET;
if (mode)
SDA_SET
else
SDA_RESET;
CLK_SET;
for(unsigned char i=0;i<8;i++)
{
CLK_RESET;
if (c & 0x80)
SDA_SET
else
SDA_RESET;
CLK_SET;
c <<= 1;
}
CS_SET;
}
/*Видео окно*/
void lcd_rect(uint32_t x, uint32_t width, uint32_t y, uint32_t height)
{
/* Set CAS Address */
lcd_SendByte(CMD,CASET);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,x);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,width);
/* Set RAS Address */
lcd_SendByte(CMD,RASET);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,y);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,height);
/* Write RAM */
lcd_SendByte(CMD,RAMWR);
}
/*Запись в GRAM*/
void lcd_wr_gram(uint16_t gram)
{
lcd_SendByte(DAT,(uint8_t)(gram>>8));
lcd_SendByte(DAT,(uint8_t)gram);
}
/*Заливка GRAM*/
void lcd_clear(void)
{
volatile uint32_t n;
lcd_rect(0,MAX_X-1,0,MAX_Y-1);
n = (MAX_X) * (MAX_Y);
do {
/* 16Bit Colour Access */
lcd_wr_gram(COL_BLUE);
} while (--n);
}
/*Инициализация*/
void lcd_init()
{
lcd_reset();
lcd_SendByte(CMD,SWRESET);
_delay_ms(120);
lcd_SendByte(CMD,SLPOUT);
_delay_ms(20);
lcd_SendByte(CMD,INVOFF);
lcd_SendByte(CMD,IDMOFF);
lcd_SendByte(CMD,NORON);
lcd_SendByte(CMD,COLMOD);
lcd_SendByte(DAT,0x05);
_delay_ms(10);
lcd_SendByte(CMD,MADCTL);
lcd_SendByte(DAT,0x08);
_delay_ms(10);
lcd_SendByte(CMD,DISPON);
_delay_ms(10);
lcd_clear();
}
void main( void )
{
// сброс порта C
GPIO_DeInit(GPIOC);
// ноги 2,4,5,6 - на выход
GPIO_Init(GPIOC,GPIO_PIN_2,GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_Init(GPIOC,GPIO_PIN_4,GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_Init(GPIOC,GPIO_PIN_5,GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_Init(GPIOC,GPIO_PIN_6,GPIO_MODE_OUT_PP_HIGH_FAST);
// тактирование ядра 16mHz
CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
lcd_init();
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval : None
*/
void assert_failed(u8* file, u32 line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
Ср май 01, 2013 19:01:38
Пн май 06, 2013 20:07:10
#include <18F252.h>
#device PASS_STRINGS=IN_RAM
#fuses H4,NOWDT,NOPUT
#use delay (clock=40000000)
#define OFS_COL 2
#define OFS_RAW 2
#define MAX_X 128
#define MAX_Y 160
#define CMD 0
#define DAT 1
/* SPFD54124 Инструкции (см даташит)*/
#define SWRESET (0x01)
#define SLPOUT (0x11)
#define NORON (0x13)
#define INVOFF (0x20)
#define DISPON (0x29)
#define CASET (0x2A)
#define RASET (0x2B)
#define RAMWR (0x2C)
#define MADCTL (0x36)
#define IDMOFF (0x38)
#define COLMOD (0x3A)
/* Формирование цвета */
#define RGB(r,g,b) (unsigned int16)((r >> 3) |((g >> 2) << 5) |((b >> 3) << 11))
/* Основные цвета */
#define COL_BLACK RGB(0,0,0)
#define COL_WHITE RGB(255,255,255)
#define COL_RED RGB(255,0,0)
#define COL_BLUE RGB(0,0,255)
#define COL_GREEN RGB(0,255,0)
#define COL_YELLOW RGB(255,255,0)
#define COL_MAGENTA RGB(255,0,255)
#define COL_AQUA RGB(0,255,255)
#define COL_PURPLE RGB(160,32,240)
#define COL_REDPINK RGB(255,50,50)
#define COL_ORANGE RGB(255,165,0)
// управление ногами rst,cs,sda,clk
#define RST PIN_C0
#define CS PIN_C1
#define SDA PIN_C7
#define CLK PIN_C6
/*Хардварный ресет драйвера*/
void lcd_reset()
{
output_high(RST);
output_high(CS);
output_high(CLK);
delay_ms(1);
output_low(RST);
output_low(CS);
delay_ms(20);
output_high(RST);
delay_ms(20);
}
void lcd_SendByte(char mode,unsigned char c)
{
output_low(CS);
output_low(CLK);
if (mode)
output_high(SDA);
else
output_low(SDA);
output_high(CLK);
unsigned char i;
for(i=0;i<8;i++)
{
output_low(CLK);
if (c & 0x80)
output_high(SDA);
else
output_low(SDA);
output_high(CLK);
c <<= 1;
}
output_high(CS);
}
/*Видео окно*/
void lcd_rect(unsigned int32 x, unsigned int32 width, unsigned int32 y, unsigned int32 height)
{
/* Set CAS Address */
lcd_SendByte(CMD,CASET);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,OFS_RAW + y);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,OFS_RAW + height);
/* Set RAS Address */
lcd_SendByte(CMD,RASET);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,OFS_COL + x);
lcd_SendByte(DAT,0);
lcd_SendByte(DAT,OFS_COL + width);
/* Write RAM */
lcd_SendByte(CMD,RAMWR);
}
/*Запись в GRAM*/
void lcd_wr_gram(unsigned int16 gram)
{
lcd_SendByte(DAT,(char)(gram>>8));
lcd_SendByte(DAT,(char)gram);
}
/*Заливка GRAM*/
void lcd_clear(unsigned int16 col)
{
volatile unsigned int32 n;
lcd_rect(0,MAX_X-1,0,MAX_Y-1);
n = (MAX_X) * (MAX_Y);
do {
/* 16Bit Colour Access */
lcd_wr_gram(col);
} while (--n);
}
/*Инициализация*/
void lcd_init()
{
lcd_reset();
lcd_SendByte(CMD,SWRESET);
delay_ms(120);
lcd_SendByte(CMD,SLPOUT);
delay_ms(20);
lcd_SendByte(CMD,INVOFF);
lcd_SendByte(CMD,IDMOFF);
lcd_SendByte(CMD,NORON);
lcd_SendByte(CMD,COLMOD);
lcd_SendByte(DAT,0x05);
delay_ms(10);
lcd_SendByte(CMD,MADCTL);
lcd_SendByte(DAT,0xa8);
delay_ms(10);
lcd_SendByte(CMD,DISPON);
delay_ms(10);
lcd_clear(COL_BLACK);
}
void main( void )
{
lcd_init();
while(true)
{
lcd_clear(COL_WHITE );
lcd_clear(COL_RED );
lcd_clear(COL_BLUE );
lcd_clear(COL_GREEN );
lcd_clear(COL_YELLOW );
lcd_clear(COL_MAGENTA );
lcd_clear(COL_AQUA );
lcd_clear(COL_REDPINK );
lcd_clear(COL_ORANGE );
}
}
Пн май 06, 2013 20:36:30
Вт май 07, 2013 23:52:45
Ср май 08, 2013 10:19:39
#include <18F252.h>
#device PASS_STRINGS=IN_RAM
#include <string.h>
#fuses H4,NOWDT,NOPUT
#use delay (clock=40000000)
const char FONT8x15[97][15] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00, // !
0x00,0x63,0x63,0x63,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // "
0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x36,0x36,0x7F,0x36,0x36,0x00,0x00,0x00, // #
0x0C,0x0C,0x3E,0x63,0x61,0x60,0x3E,0x03,0x03,0x43,0x63,0x3E,0x0C,0x0C,0x00, // $
0x00,0x00,0x00,0x00,0x00,0x61,0x63,0x06,0x0C,0x18,0x33,0x63,0x00,0x00,0x00, // %
0x00,0x00,0x00,0x1C,0x36,0x36,0x1C,0x3B,0x6E,0x66,0x66,0x3B,0x00,0x00,0x00, // &
0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // '
0x00,0x00,0x0C,0x18,0x18,0x30,0x30,0x30,0x30,0x18,0x18,0x0C,0x00,0x00,0x00, // (
0x00,0x00,0x18,0x0C,0x0C,0x06,0x06,0x06,0x06,0x0C,0x0C,0x18,0x00,0x00,0x00, // )
0x00,0x00,0x00,0x00,0x42,0x66,0x3C,0xFF,0x3C,0x66,0x42,0x00,0x00,0x00,0x00, // *
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0xFF,0x18,0x18,0x18,0x00,0x00,0x00,0x00, // +
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00, // ,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00, // .
0x00,0x00,0x01,0x03,0x07,0x0E,0x1C,0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,0x00, // / (forward slash)
0x00,0x00,0x3E,0x63,0x63,0x63,0x67,0x6B,0x73,0x63,0x63,0x3E,0x00,0x00,0x00, // 0 0x30
0x00,0x00,0x0C,0x1C,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3F,0x00,0x00,0x00, // 1
0x00,0x00,0x3E,0x63,0x03,0x06,0x0C,0x18,0x30,0x61,0x63,0x7F,0x00,0x00,0x00, // 2
0x00,0x00,0x3E,0x63,0x03,0x03,0x1E,0x03,0x03,0x03,0x63,0x3E,0x00,0x00,0x00, // 3
0x00,0x00,0x06,0x0E,0x1E,0x36,0x66,0x66,0x7F,0x06,0x06,0x0F,0x00,0x00,0x00, // 4
0x00,0x00,0x7F,0x60,0x60,0x60,0x7E,0x03,0x03,0x63,0x73,0x3E,0x00,0x00,0x00, // 5
0x00,0x00,0x1C,0x30,0x60,0x60,0x7E,0x63,0x63,0x63,0x63,0x3E,0x00,0x00,0x00, // 6
0x00,0x00,0x7F,0x63,0x03,0x06,0x06,0x0C,0x0C,0x18,0x18,0x18,0x00,0x00,0x00, // 7
0x00,0x00,0x3E,0x63,0x63,0x63,0x3E,0x63,0x63,0x63,0x63,0x3E,0x00,0x00,0x00, // 8
0x00,0x00,0x3E,0x63,0x63,0x63,0x63,0x3F,0x03,0x03,0x06,0x3C,0x00,0x00,0x00, // 9
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00, // :
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00, // ;
0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00, // <
0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00, // =
0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00,0x00, // >
0x00,0x00,0x3E,0x63,0x63,0x06,0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x00,0x00, // ?
0x00,0x00,0x3E,0x63,0x63,0x6F,0x6B,0x6B,0x6E,0x60,0x60,0x3E,0x00,0x00,0x00, // @ 0x40
0x00,0x00,0x08,0x1C,0x36,0x63,0x63,0x63,0x7F,0x63,0x63,0x63,0x00,0x00,0x00, // A
0x00,0x00,0x7E,0x33,0x33,0x33,0x3E,0x33,0x33,0x33,0x33,0x7E,0x00,0x00,0x00, // B
0x00,0x00,0x1E,0x33,0x61,0x60,0x60,0x60,0x60,0x61,0x33,0x1E,0x00,0x00,0x00, // C
0x00,0x00,0x7C,0x36,0x33,0x33,0x33,0x33,0x33,0x33,0x36,0x7C,0x00,0x00,0x00, // D
0x00,0x00,0x7F,0x33,0x31,0x34,0x3C,0x34,0x30,0x31,0x33,0x7F,0x00,0x00,0x00, // E
0x00,0x00,0x7F,0x33,0x31,0x34,0x3C,0x34,0x30,0x30,0x30,0x78,0x00,0x00,0x00, // F
0x00,0x00,0x1E,0x33,0x61,0x60,0x60,0x6F,0x63,0x63,0x37,0x1D,0x00,0x00,0x00, // G
0x00,0x00,0x63,0x63,0x63,0x63,0x7F,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00, // H
0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00, // I
0x00,0x00,0x0F,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00,0x00,0x00, // J
0x00,0x00,0x73,0x33,0x36,0x36,0x3C,0x36,0x36,0x33,0x33,0x73,0x00,0x00,0x00, // K
0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x33,0x7F,0x00,0x00,0x00, // L
0x00,0x00,0x63,0x77,0x7F,0x6B,0x63,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00, // M
0x00,0x00,0x63,0x63,0x73,0x7B,0x7F,0x6F,0x67,0x63,0x63,0x63,0x00,0x00,0x00, // N
0x00,0x00,0x1C,0x36,0x63,0x63,0x63,0x63,0x63,0x63,0x36,0x1C,0x00,0x00,0x00, // O
0x00,0x00,0x7E,0x33,0x33,0x33,0x3E,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, // P 0x50
0x00,0x00,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,0x6B,0x6F,0x3E,0x06,0x07,0x00, // Q
0x00,0x00,0x7E,0x33,0x33,0x33,0x3E,0x36,0x36,0x33,0x33,0x73,0x00,0x00,0x00, // R
0x00,0x00,0x3E,0x63,0x63,0x30,0x1C,0x06,0x03,0x63,0x63,0x3E,0x00,0x00,0x00, // S
0x00,0x00,0xFF,0xDB,0x99,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00, // T
0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x00,0x00,0x00, // U
0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x36,0x1C,0x08,0x00,0x00,0x00, // V
0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x6B,0x6B,0x7F,0x36,0x36,0x00,0x00,0x00, // W
0x00,0x00,0xC3,0xC3,0x66,0x3C,0x18,0x18,0x3C,0x66,0xC3,0xC3,0x00,0x00,0x00, // X
0x00,0x00,0xC3,0xC3,0xC3,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00, // Y
0x00,0x00,0x7F,0x63,0x43,0x06,0x0C,0x18,0x30,0x61,0x63,0x7F,0x00,0x00,0x00, // Z
0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00,0x00, // [
0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,0x00, // \ (back slash)
0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00, // ]
0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00, // _
0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ` 0x60
0x00,0x00,0x00,0x00,0x00,0x3C,0x46,0x06,0x3E,0x66,0x66,0x3B,0x00,0x00,0x00, // a
0x00,0x00,0x70,0x30,0x30,0x3C,0x36,0x33,0x33,0x33,0x33,0x6E,0x00,0x00,0x00, // b
0x00,0x00,0x00,0x00,0x00,0x3E,0x63,0x60,0x60,0x60,0x63,0x3E,0x00,0x00,0x00, // c
0x00,0x00,0x0E,0x06,0x06,0x1E,0x36,0x66,0x66,0x66,0x66,0x3B,0x00,0x00,0x00, // d
0x00,0x00,0x00,0x00,0x00,0x3E,0x63,0x63,0x7E,0x60,0x63,0x3E,0x00,0x00,0x00, // e
0x00,0x00,0x1C,0x36,0x32,0x30,0x7C,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, // f
0x00,0x00,0x00,0x00,0x00,0x3B,0x66,0x66,0x66,0x66,0x3E,0x06,0x66,0x3C,0x00, // g
0x00,0x00,0x70,0x30,0x30,0x36,0x3B,0x33,0x33,0x33,0x33,0x73,0x00,0x00,0x00, // h
0x00,0x00,0x0C,0x0C,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00, // i
0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // j
0x00,0x00,0x70,0x30,0x30,0x33,0x33,0x36,0x3C,0x36,0x33,0x73,0x00,0x00,0x00, // k
0x00,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00, // l
0x00,0x00,0x00,0x00,0x00,0x6E,0x7F,0x6B,0x6B,0x6B,0x6B,0x6B,0x00,0x00,0x00, // m
0x00,0x00,0x00,0x00,0x00,0x6E,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x00, // n
0x00,0x00,0x00,0x00,0x00,0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00,0x00,0x00, // o
0x00,0x00,0x00,0x00,0x00,0x6E,0x33,0x33,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // p 0x70
0x00,0x00,0x00,0x00,0x00,0x3B,0x66,0x66,0x66,0x66,0x3E,0x06,0x06,0x0F,0x00, // q
0x00,0x00,0x00,0x00,0x00,0x6E,0x3B,0x33,0x30,0x30,0x30,0x78,0x00,0x00,0x00, // r
0x00,0x00,0x00,0x00,0x00,0x3E,0x63,0x38,0x0E,0x03,0x63,0x3E,0x00,0x00,0x00, // s
0x00,0x00,0x08,0x18,0x18,0x7E,0x18,0x18,0x18,0x18,0x1B,0x0E,0x00,0x00,0x00, // t
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3B,0x00,0x00,0x00, // u
0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x36,0x36,0x1C,0x1C,0x08,0x00,0x00,0x00, // v
0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x6B,0x6B,0x7F,0x36,0x00,0x00,0x00, // w
0x00,0x00,0x00,0x00,0x00,0x63,0x36,0x1C,0x1C,0x1C,0x36,0x63,0x00,0x00,0x00, // x
0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x3F,0x03,0x06,0x3C,0x00, // y
0x00,0x00,0x00,0x00,0x00,0x7F,0x66,0x0C,0x18,0x30,0x63,0x7F,0x00,0x00,0x00, // z
0x00,0x00,0x0E,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0E,0x00,0x00,0x00, // {
0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00, // |
0x00,0x00,0x70,0x18,0x18,0x18,0x0E,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00, // }
0x00,0x00,0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~
0x00,0x70,0xD8,0xD8,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define OFS_COL 2
#define OFS_RAW 2
#define MAX_Y 128
#define MAX_X 160
#define CMD 0
#define DAT 1
/* SPFD54124 Инструкции (см даташит)*/
#define NO_OP (0x00)
#define SWRESET (0x01)
#define SLPOUT (0x11)
#define NORON (0x13)
#define INVOFF (0x20)
#define DISPON (0x29)
#define CASET (0x2A)
#define RASET (0x2B)
#define RAMWR (0x2C)
#define MADCTL (0x36)
#define IDMOFF (0x38)
#define COLMOD (0x3A)
/* Формирование цвета */
#define RGB(r,g,b) (unsigned long)((r >> 3) |((g >> 2) << 5) |((b >> 3) << 11))
/* Основные цвета */
#define COL_BLACK RGB(0,0,0)
#define COL_WHITE RGB(255,255,255)
#define COL_RED RGB(255,0,0)
#define COL_BLUE RGB(0,0,255)
#define COL_GREEN RGB(0,255,0)
#define COL_YELLOW RGB(255,255,0)
#define COL_MAGENTA RGB(255,0,255)
#define COL_AQUA RGB(0,255,255)
#define COL_PURPLE RGB(160,32,240)
#define COL_REDPINK RGB(255,50,50)
#define COL_ORANGE RGB(255,165,0)
// управление ногами rst,cs,sda,clk
#define RST PIN_C0
#define CS PIN_C1
#define SDA PIN_C7
#define CLK PIN_C6
/*Хардварный ресет драйвера*/
void lcd_reset()
{
output_high(RST);
output_high(CS);
output_high(CLK);
delay_ms(1);
output_low(RST);
output_low(CS);
delay_ms(20);
output_high(RST);
delay_ms(20);
}
/*Запись 8bit*/
void lcd_SendByte(char mode,unsigned char c)
{
output_low(CS);
output_low(CLK);
if (mode)
output_high(SDA);
else
output_low(SDA);
output_high(CLK);
unsigned char i;
for(i=0;i<8;i++)
{
output_low(CLK);
if (c & 0x80)
output_high(SDA);
else
output_low(SDA);
output_high(CLK);
c <<= 1;
}
output_high(CS);
}
/*Запись 16bit*/
void lcd_wr_gram(unsigned long gram)
{
lcd_SendByte(DAT,(char)(gram>>8));
lcd_SendByte(DAT,(char)gram);
}
/*Видео окно*/
void lcd_win(unsigned long x, unsigned long y, unsigned long x1, unsigned long y1)
{
/* Set CAS Address */
lcd_SendByte(CMD,CASET);
lcd_wr_gram(OFS_COL + x);
lcd_wr_gram(OFS_COL + x1);
/* Set RAS Address */
lcd_SendByte(CMD,RASET);
lcd_wr_gram(OFS_RAW + y);
lcd_wr_gram(OFS_RAW + y1);
/* Write RAM */
lcd_SendByte(CMD,RAMWR);
}
/*Заливка GRAM*/
void lcd_fill(unsigned long x, unsigned long y, unsigned long x1, unsigned long y1, unsigned long col)
{
unsigned long n,h,w;
lcd_win(x,y,x1,y1);
h = (y1+1)-y;
w = (x1+1)-x;
n = h * w;
do
{
lcd_wr_gram(col);
} while (--n);
}
/*Инициализация*/
void lcd_init()
{
lcd_reset();
lcd_SendByte(CMD,SWRESET);
delay_ms(120);
lcd_SendByte(CMD,SLPOUT);
lcd_SendByte(CMD,COLMOD);
lcd_SendByte(DAT,0x05);
lcd_SendByte(CMD,MADCTL);
lcd_SendByte(DAT,0xa8);
lcd_SendByte(CMD,DISPON);
}
#define CHAR_W 8
#define CHAR_H 15
void put_char(unsigned long x, unsigned long y, char c, unsigned long color, unsigned long bgcolor)
{
unsigned char h,ch,p,mask;
lcd_win(x,y,x+CHAR_W-1,y+CHAR_H-1);
for (h=0; h<CHAR_H; h++)
{
ch=FONT8x15[ c-32 ][h];
mask = 0x80;
for (p=0; p<CHAR_W; p++)
{
if (ch & mask)
{
lcd_wr_gram(color);
}
else
{
lcd_wr_gram(bgcolor);
}
mask=mask/2;
}
}
}
void put_string(unsigned long x, unsigned long y, char *str, unsigned long color,unsigned long bgcolor)
{
unsigned char j;
j=0;
while (j<strlen(str))
{
put_char(x+j*CHAR_W,y,str[j], color, bgcolor);
j++;
}
}
void put_pixel(unsigned long x, unsigned long y, unsigned long color)
{
lcd_win(x,y,x+1,y+1);
lcd_wr_gram(color);
}
void put_circle(unsigned long xcenter, unsigned long ycenter, long rad, unsigned long color)
{
signed int tswitch,y1,x1 = 0;
signed char d;
xcenter = 0 + xcenter;
d = ycenter - xcenter;
y1 = rad;
tswitch = 3 - 2 * rad;
while (x1 <= y1)
{
put_pixel(xcenter + x1, ycenter + y1, color);
put_pixel(xcenter + x1, ycenter - y1, color);
put_pixel(xcenter - x1, ycenter + y1, color);
put_pixel(xcenter - x1, ycenter - y1, color);
put_pixel(ycenter + y1 - d, ycenter + x1, color);
put_pixel(ycenter + y1 - d, ycenter - x1, color);
put_pixel(ycenter - y1 - d, ycenter + x1, color);
put_pixel(ycenter - y1 - d, ycenter - x1, color);
if (tswitch < 0) tswitch += (4 * x1 + 6);
else
{
tswitch += (4 * (x1 - y1) + 10);
y1--;
}
x1++;
}
//CS=1;
}
const char string[]= "NOKIA 2660 LCD DEMO";
const char string1[]=" PIC18F252 ";
void main( void )
{
lcd_init();
lcd_fill(0,0,159,127 ,COL_BLUE );
put_circle(20,20,10,COL_WHITE);
put_string(4,50,string,COL_GREEN,COL_BLUE);
put_string(4,65,string1,COL_YELLOW,COL_BLUE);
while(true)
{
}
}
Ср май 08, 2013 11:53:29
... ну так почему не использовать аппаратный SPI? ... или не понял из-за чего "тормозит" заливка....maxlab писал(а):Здравствуйте! Не устроила меня скорость заливки на STM8.
Ср май 08, 2013 13:27:42
ChipKiller писал(а):... ну так почему не использовать аппаратный SPI? ... или не понял из-за чего "тормозит" заливка....maxlab писал(а):Здравствуйте! Не устроила меня скорость заливки на STM8.
Ср май 08, 2013 13:44:30
.. понятно, что чем больше, тем лучше. Просто программный SPI на stm8 будет поменьше 1mbit. После праздников попробую к stm32 подключить, только наверное Nokia1616 возьму - не охота со шлейфом ковыряться....maxlab писал(а):то все равно 8mbit в секунду. Это мало. В сотовых используют АРМ с тактовой от 160 мгц.
Ср май 08, 2013 14:06:13
Пн май 13, 2013 10:44:20
Пн май 13, 2013 18:24:52
Ср май 22, 2013 09:24:57
Вт май 28, 2013 18:15:07