
-
UID:1023450
-
- 注册时间2011-12-16
- 最后登录2022-04-17
- 在线时间2350小时
-
-
访问TA的空间加好友用道具
|
以前 我修改了u8glib,使其支持ks0107/0108 让arduino u8glib支持ks0107/0108芯片组 192X64液晶 http://bbs.mydigit.cn/read.php?tid=1504464; 虽然u8glib支持很多的芯片、而且用C++引用和定制方法简单,但所有应用代码需放在loop中,这种构架更适应于无控制芯片的LCD; 因此,我还试用了另外一个库:GLCD,功能并不差,只是支持的芯片少。但支持ks0107/0108;因此我稍加修改,就支持19264了,也非常好用; 最近几天,有坛友询问ks0107/0108 19264三屏三片选驱动,我再次研究了一下该库,其实其核心代码也支持三屏三片选,因此为坛友写了个三屏三片选的配置文件,同时也放在坛里供需要的朋友,如需要进行其它移植和配置,这里附个简明的教程: 原移植和配置步骤: 一 针对jd19264 M64/128板子并按照说明增加了下述两个文件: 1 3屏2片选驱动配置文件:用原始文件 src/config/ks0108_Panel.h复制副本并修改而成: src/config/ks0108-192x64_Panel.h 2 对M4/128特定板子的连接方式配置:用src/config/ks0108_Mega.h复制副本并修改而成: src/config/ks0108_m64128.h 二 修改src/glcd_Config.h 增加相应调用 ks0108-192x64_Panel.h 的选项 第67行 去除注释 // 这样就能调用 config/ks0108-192x64_Panel.h 三 说明,在ks0108-192x64_Panel.h line 139~149 增加了根据定义__AVR_ATmega128__或__AVR_ATmega64__,自动装入ks0108_m64128.h的程序行,如果在其它板子如 1280/2560/644/644P等,则修改或添加相应的硬件连接文件; 以上两个文件是我以前针对 M64/128 JD19264写的文件,硬件不是这个条件的话,请自行修改; 配置自己的硬件环境实例: (ks0108芯片 19264 三屏三片选) 增加了一个文件:拷贝合适的配置文件ks0108_Panel.h副本,并更名为 ks0108-192x64_3cs.h line 42 修改为三片选 #define NBR_CHIP_SELECT_PINS 3 使用: 1 修改src/glcd_Config.h 第67行 加 注释 // 这样就能不会调用 config/ks0108-192x64_Panel.h 第68行 去除行首 注释 // 这样就能调用 config/ks0108-192x64_3cs.h(这是我修改好的) 其它的参数,均需要按实际情况设置,其中的说明很详细的。修改没有多大的困难。 2 根据你具体连接的板子,修改ks0108_m64128.h 文件(或新建一个其它名称的): 主要有: line 28~30 数据端口直接输出(速度快) 如未定义数据端口,则需要对 d0~d7 分别定义 (line 32~41) 对2cs 脚定义(line 46~47) 在 ks0108-192x64_3cs.h 中已定义NBR_CHIP_SELECT_PINS 3 所以还需要在line 50 定义片选3脚号 glcdCSEL3 定义 RW DI EN 脚号,line 57~59 如有reset脚可控,在line 61 如有背光可控 在line 66 后记: 我在ks0108-192x64_Panel.h 42行 修改为: #ifndef NBR_CHIP_SELECT_PINS #define NBR_CHIP_SELECT_PINS 2 #endif 这样 ks0108缺省2片选,如在编译环境有编译选项: -DNBR_CHIP_SELECT_PINS=3 选择三片选 或修改为: #ifndef NBR_CHIP_SELECT_PINS #define NBR_CHIP_SELECT_PINS 3 #endif 就变成缺省3片选了。 附:ks0108-192x64_3cs.h - /*
- * ks0108-192x64_Panel.h - User specific configuration for Arduino GLCD library
- *
- * Use this file to set LCD panel parameters
- * This version is for a 192x64 ks0108 display
- * This file uses a board specific pin assignment file based on the board selected in the IDE
- *
- */
- #ifndef GLCD_PANEL_CONFIG_H
- #define GLCD_PANEL_CONFIG_H
- /*
- * define name for panel configuration
- */
- #define glcd_PanelConfigName "ks0108-192x64"
- /*********************************************************/
- /* Configuration for LCD panel specific configuration */
- /*********************************************************/
- #define DISPLAY_WIDTH 192
- #define DISPLAY_HEIGHT 64
- // panel controller chips
- #define CHIP_WIDTH 64 // pixels per chip
- #define CHIP_HEIGHT 64 // pixels per chip
- /*
- * the following is the calculation of the number of chips - do not change
- */
- #define glcd_CHIP_COUNT (((DISPLAY_WIDTH + CHIP_WIDTH - 1) / CHIP_WIDTH) * ((DISPLAY_HEIGHT + CHIP_HEIGHT -1) / CHIP_HEIGHT))
- /*********************************************************/
- /* Chip Select Configuration */
- /*********************************************************/
- /*
- * Change the following define to match the number of Chip Select pins for this panel
- * Most panels use two pins for chip select,
- * but check your datasheet to see if a different number is required
- */
- #define NBR_CHIP_SELECT_PINS 3 // the number of chip select pins required for this panel
- /*
- * The following conditional statements determine the relationship between the chip select
- * pins and the physical chips.
- * If the chips are displayed in the wrong order, you can swap the glcd_CHIPx defines
- */
- /*
- * Defines for Panels using two Chip Select pins
- */
- #if NBR_CHIP_SELECT_PINS == 2 //2cspin
- /*
- * Two Chip panels using two select pins (the most common panel type)
- */
- #if glcd_CHIP_COUNT == 2 // 2screen 2cspin
- #define glcd_CHIP0 glcdCSEL1,HIGH, glcdCSEL2,LOW
- #define glcd_CHIP1 glcdCSEL1,LOW, glcdCSEL2,HIGH
- /*
- * Three Chip panel using two select pins
- * 第二屏错需交换
- */
- #elif glcd_CHIP_COUNT == 3 //3screen 2cspin
- #define glcd_CHIP0 glcdCSEL1,LOW, glcdCSEL2,LOW
- #define glcd_CHIP1 glcdCSEL1,HIGH, glcdCSEL2,LOW
- #define glcd_CHIP2 glcdCSEL1,LOW, glcdCSEL2,HIGH
- /*
- * Four Chip panel using two select pins
- */
- #elif glcd_CHIP_COUNT == 4 //4screen 2cspin
- #define glcd_CHIP0 glcdCSEL1,LOW, glcdCSEL2,LOW
- #define glcd_CHIP1 glcdCSEL1,HIGH, glcdCSEL2,LOW
- #define glcd_CHIP2 glcdCSEL1,HIGH, glcdCSEL2,HIGH
- #define glcd_CHIP3 glcdCSEL1,LOW, glcdCSEL2,HIGH
- #endif
- /*
- * Defines for Two Chip panels using one Chip Select pin
- */
- #elif (NBR_CHIP_SELECT_PINS == 1 && glcd_CHIP_COUNT == 2) // 2screen 1cspin 128x64
- #define glcd_CHIP0 glcdCSEL1,LOW
- #define glcd_CHIP1 glcdCSEL1,HIGH
- /*
- * Defines for Three Chip panels using three select pins
- */
- #elif (NBR_CHIP_SELECT_PINS == 3 && glcd_CHIP_COUNT == 3) // 3screen 3cspin 192x64
- #define glcd_CHIP0 glcdCSEL1,HIGH, glcdCSEL2,LOW, glcdCSEL3,LOW
- #define glcd_CHIP1 glcdCSEL1,LOW, glcdCSEL2,HIGH, glcdCSEL3,LOW
- #define glcd_CHIP2 glcdCSEL1,LOW, glcdCSEL2,LOW, glcdCSEL3,HIGH
- /*
- * Defines for Four Chip panel using four select pins
- */
- #elif (NBR_CHIP_SELECT_PINS == 4 && glcd_CHIP_COUNT == 4) //// 4screen 4cspin
- #define glcd_CHIP0 glcdCSEL1,HIGH, glcdCSEL2,LOW, glcdCSEL3,LOW, glcdCSEL4,LOW
- #define glcd_CHIP1 glcdCSEL1,LOW, glcdCSEL2,HIGH, glcdCSEL3,LOW, glcdCSEL4,LOW
- #define glcd_CHIP2 glcdCSEL1,LOW, glcdCSEL2,LOW, glcdCSEL3,HIGH, glcdCSEL4,LOW
- #define glcd_CHIP3 glcdCSEL1,LOW, glcdCSEL2,LOW, glcdCSEL3,LOW, glcdCSEL4,HIGH
- /*
- * Here if the Number of Chip Selects is not supported for the selected panel size and chip size
- */
- #else //
- #error "The number of Chips and Chip Select pins does not match an option in ks0108-192x64_3cs.h"
- #error "Check that the number of Chip Select pins is correct for the configured panel size"
- #endif
- /*********************************************************/
- /* End of Chip Select Configuration */
- /*********************************************************/
- /*
- * The following defines are for panel specific low level timing.
- *
- * See your data sheet for the exact timing and waveforms.
- * All defines below are in nanoseconds.
- */
- #define GLCD_tDDR 320 /* Data Delay time (E high to valid read data) */
- #define GLCD_tAS 140 /* Address setup time (ctrl line changes to E HIGH */
- #define GLCD_tDSW 200 /* Data setup time (data lines setup to dropping E) */
- #define GLCD_tWH 450 /* E hi level width (minimum E hi pulse width) */
- #define GLCD_tWL 450 /* E lo level width (minimum E lo pulse width) */
- /*
- * The code below selects a configuration file for pin assignment based on the board selected in the IDE
- * These configurations are compatible with wiring used in earlier versions of the library
- * WARNING: When adding new board types it is not as simple as just editing these lines.
- * There is also a dependency on the file glcd/include/arduino_io.h which does the arduino pin mappings
- */
-
- #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
- #include "config/ks0108_Mega.h" // config for mega 1280/2560 board
- #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
- #include "config/ks0108_Sanguino.h" // config for Sanguino or other ATmega644/p board
- #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U4__)// Teensy
- #include "config/ks0108_Teensy.h" // config for Teensy and Teensy++
- #elif defined(__AVR_ATmega128__) || defined(__AVR_ATmega64__)
- #include "config/ks0108_m64128.h" // config for mega 1280/2560 board
- #else
- #include "config/ks0108_Arduino.h" // config file for standard Arduino using documented wiring
- #endif
- #include "device/ks0108_Device.h"
- #endif //GLCD_PANEL_CONFIG_H
ks0108_m64128.h - /*
- * ks0108_Arduino.h - User specific configuration for Arduino GLCD library
- *
- * Use this file to set io pins
- * This version is for a standard ks0108 display
- * connected using the default Arduino wiring
- *
- */
- #ifndef GLCD_PIN_CONFIG_H
- #define GLCD_PIN_CONFIG_H
- /*
- * define name for pin configuration
- */
- #define glcd_PinConfigName "ks0108_m64128"
- /*********************************************************/
- /* Configuration for assigning LCD bits to Arduino Pins */
- /*********************************************************/
- /* Data pin definitions by huaweiwx@sina.com 2016.2.3
- */
-
- // d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
- //PC_0, PC_1, PC_2, PC_3, PC_4, PC_5, PC_6, PC_7, PG_1, PD_5, PD_6, PD_7, PG_0, PA_1); //for M64_GPS
- //直接定义数据端口,快速输出/输入
- #define glcdDataPortIN PINC
- #define glcdDataPortOUT PORTC
- #define glcdDataPortDDR DDRC
- #ifndef glcdDataPortIN
- #define glcdData0Pin PIN_C0
- #define glcdData1Pin PIN_C1
- #define glcdData2Pin PIN_C2
- #define glcdData3Pin PIN_C3
- #define glcdData4Pin PIN_C4
- #define glcdData5Pin PIN_C5
- #define glcdData6Pin PIN_C6
- #define glcdData7Pin PIN_C7
- #endif
- /* Arduino pins used for Commands
- * default assignment uses the first five analog pins
- */
- #define glcdCSEL1 PIN_D5
- #define glcdCSEL2 PIN_D6
- #if NBR_CHIP_SELECT_PINS > 2
- #define glcdCSEL3 PIN_XX // third chip select if needed
- #endif
- #if NBR_CHIP_SELECT_PINS > 3
- #define glcdCSEL4 PIN_XX // fourth chip select if needed
- #endif
- #define glcdRW PIN_G0
- #define glcdDI PIN_D7
- #define glcdEN PIN_G1
- // Reset Bit - uncomment the next line if reset is connected to an output pin
- //#define glcdRES PIN_A1 // Reset Bit
- //huawei add
- #define LCDBACK_PIN PA_4
- #ifdef LCDBACK_PIN
- #define LcdBackOn() digitalWrite(LCDBACK_PIN, 0)
- #define LcdBackOff() digitalWrite(LCDBACK_PIN, 1)
- #endif
- #endif //GLCD_PIN_CONFIG_H
其它文件你可以网上百度下载,按我上述内容修改相关文件,也可直接下载我修改好的全部文件: 附件:我改好的全部库文件:GLCD 使用:解压后将glcd文件夹copy到 arduino/libraries 中。 [ 此帖被huaweiwx在2016-09-19 14:15重新编辑 ]
|