找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2|回复: 0
收起左侧

常用ST7657的stc8和stc89R52单片机程序

[复制链接]
ID:380108 发表于 2025-8-19 17:33 | 显示全部楼层 |阅读模式
常用ST7657的stc8和stc89R52程序,需要修改MCU头文件以及延迟和对比度。

51hei.png

  1. #include <stdio.h>
  2. #include <pigpio.h>
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <sys/ioctl.h>

  8. /************************************************************************/
  9. /* Rpi-ST7565 LCD Connection with 40pin RpiB+ or 26pin RpiB             */
  10. /************************************************************************/
  11.    
  12. /*  
  13.     Rpi Connector      ST7565 LCD
  14.     ------------------------------
  15.     3.3v (Pin01)     - LCD Back A
  16.     GND  (Pin09)     - LCD Back K
  17.     GND  (Pin06)     - GND
  18.     3.3V (Pin17)     - VCC

  19.     GPIO10(SPI_MOSI) - SID
  20.     GPIO11(SPI_CLK)  - SCLK
  21.     GPIO24           - A0
  22.     GPIO25           - nRST
  23.     GPIO08(SPI_CE0N) - nCS   */
  24.    
  25. /************************************************************************/

  26. /************************************************************************/
  27. /* Global Variables                                                     */
  28. /************************************************************************/

  29. /* Global SPI bus handle */
  30. static int gx_spihandle = -1;

  31. /* Global position storage for the Cursor */
  32. static uint16_t gw_row = 0;
  33. static uint16_t gw_column = 0;

  34. /* Adafruit White LED ST7565 LCD
  35.    128 x 64 pixels
  36.    - This needs to be enabled if using the Adafruit version
  37.     of the LCD. The problem is with the weird page memory locations.
  38.     Also the Number of columns is one on excess of 128.
  39.    
  40.    - Comment this out when using the Normal LCD version which does
  41.    not have the changeover in the page memory and the additional line.
  42.   
  43.    
  44. */
  45. //#define ADAFRUIT_ST7565_LCD

  46. /************************************************************************/
  47. /* LCD Pins                                                             */
  48. /************************************************************************/

  49. #define LCD_SID     10
  50. #define LCD_SCK     11
  51. #define LCD_A0      24
  52. #define LCD_nRST    25
  53. #define LCD_nCS     8

  54. /************************************************************************/
  55. /* Commands                                                             */
  56. /************************************************************************/

  57. #define BLACK 1
  58. #define WHITE 0

  59. #define ST7565_LCD_CMD_DISPLAY_OFF           0xAE
  60. #define ST7565_LCD_CMD_DISPLAY_ON            0xAF

  61. #define ST7565_LCD_CMD_SET_DISP_START_LINE   0x40
  62. #define ST7565_LCD_CMD_SET_PAGE              0xB0

  63. #define ST7565_LCD_CMD_SET_COLUMN_UPPER      0x10
  64. #define ST7565_LCD_CMD_SET_COLUMN_LOWER      0x00

  65. #define ST7565_LCD_CMD_SET_ADC_NORMAL        0xA0
  66. #define ST7565_LCD_CMD_SET_ADC_REVERSE       0xA1

  67. #define ST7565_LCD_CMD_SET_DISP_NORMAL       0xA6
  68. #define ST7565_LCD_CMD_SET_DISP_REVERSE      0xA7

  69. #define ST7565_LCD_CMD_SET_ALLPTS_NORMAL     0xA4
  70. #define ST7565_LCD_CMD_SET_ALLPTS_ON         0xA5
  71. #define ST7565_LCD_CMD_SET_BIAS_9            0xA2
  72. #define ST7565_LCD_CMD_SET_BIAS_7            0xA3

  73. #define ST7565_LCD_CMD_RMW                   0xE0
  74. #define ST7565_LCD_CMD_RMW_CLEAR             0xEE
  75. #define ST7565_LCD_CMD_INTERNAL_RESET        0xE2
  76. #define ST7565_LCD_CMD_SET_COM_NORMAL        0xC0
  77. #define ST7565_LCD_CMD_SET_COM_REVERSE       0xC8
  78. #define ST7565_LCD_CMD_SET_POWER_CONTROL     0x28
  79. #define ST7565_LCD_CMD_SET_RESISTOR_RATIO    0x20
  80. #define ST7565_LCD_CMD_SET_VOLUME_FIRST      0x81
  81. #define ST7565_LCD_CMD_SET_VOLUME_SECOND     0x0
  82. #define ST7565_LCD_CMD_SET_STATIC_OFF        0xAC
  83. #define ST7565_LCD_CMD_SET_STATIC_ON         0xAD
  84. #define ST7565_LCD_CMD_SET_STATIC_REG        0x0
  85. #define ST7565_LCD_CMD_SET_BOOSTER_FIRST     0xF8
  86. #define ST7565_LCD_CMD_SET_BOOSTER_234       0
  87. #define ST7565_LCD_CMD_SET_BOOSTER_5         1
  88. #define ST7565_LCD_CMD_SET_BOOSTER_6         3
  89. #define ST7565_LCD_CMD_NOP                   0xE3
  90. #define ST7565_LCD_CMD_TEST                  0xF0

  91. /************************************************************************/
  92. /* Font Definitions                                                     */
  93. /************************************************************************/
  94. /**
  95. * 5x7 LCD font 'flipped' for the ST7565 - public domain
  96. * @note This is a 256 character font. Delete glyphs in order to save Flash
  97. */
  98. /* Controls the definition of the Font array and character spcing */
  99. //#define FULL_FONT
  100. static const uint8_t gca_font[] =
  101. {
  102. #ifdef FULL_FONT
  103.   0x0, 0x0, 0x0, 0x0, 0x0,          /* ASC(00) */
  104.   0x7C, 0xDA, 0xF2, 0xDA, 0x7C,     /* ASC(01) */
  105.   0x7C, 0xD6, 0xF2, 0xD6, 0x7C,     /* ASC(02) */
  106.   0x38, 0x7C, 0x3E, 0x7C, 0x38,   /* ASC(03) */
  107.   0x18, 0x3C, 0x7E, 0x3C, 0x18,   /* ASC(04) */
  108.   0x38, 0xEA, 0xBE, 0xEA, 0x38,   /* ASC(05) */
复制代码

下载: st7565c51.zip (146.5 KB, 下载次数: 0)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表