数码之家

 找回密码
 立即注册
搜索
查看: 6688|回复: 6

[STM] 搞定了三年前的小屏幕,SSD1309驱动后续

[复制链接]
发表于 2020-4-2 09:04:20 | 显示全部楼层 |阅读模式
      先看效果,实现了对齐访问和非对齐访问。对齐访问是指在每个Page的起始和结束都填满数据,这样也就是直接写入一个字节的显示数据就行了;非对齐访问是指任意地向任何一个Page的中部开始填入数据,结束位置可以在本Page或者之后的Page的中部,这个需要读出原来一个或者多个Page的数据,与新的数据合并处理后再回写,难度更大,效率更低。
      其中前面的画点就是普通的DrawPoint方法,在X=0,Y<-[0-7]区间画了8个点;后面的画矩形有对齐绘制和非对齐绘制,使用了对齐的矩形填充任意宽度,8x8,16x16,还有非对齐的8x8,12x12,16x16方法;最后显示使用了字符串输出函数Printf,在任意位置输出任意可打印的ASCII字符,不支持中文。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

打赏

参与人数 1家元 +15 收起 理由
人艰不拆了 + 15

查看全部打赏

发表于 2020-4-2 09:07:02 | 显示全部楼层
恭喜恭喜,我也有这屏。可以共享吗?:shy:
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-4-2 09:16:23 | 显示全部楼层
      之前的问题看这里:https://www.mydigit.cn/forum.php?mod=viewthread&tid=138123&extra=
      基本没人一针见血指出其中的问题,只有20楼说了可能是刷新速度快了,相对接近真相!反正我之前说过“原厂的Datasheet包括模块方案整合商的说明书都没有提到的一些细节,我觉得不成功可能就是这样”。没错细节问题!!刷新速度不是你们想的那样,不能用SPI连续灌入大量数据,否则响应不过来。一般地,这类屏幕都有8080,6800模式,在并口模式下是要求在写入后读取忙信号直到忙信号消失后在进行下一次写入。但是对于SPI接口而言没有这个机制,因为SPI不能读。所以我想SPI应该支持连续写。事实上确实可以,但是连续写完命令流(设置页,段地址起始,结束;滚动;对比度。所有的命令汇合成命令串,由DMA驱动SPI一次发玩)以后,必须间断一定的时间,再发送显示数据流!!!注意,不是发完一个字节的数据和命令后休息一下再发下一个字节,是发玩一整串命令流或者数据流后间断一下再发下一串流。在SPI下,数据单位你们可以认为是字节流,而不是并口模式下的字节,所以每两个数据单位之间应该有所间隔,否则会造成数据刷新频率过快无法响应!!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-4-2 09:20:14 | 显示全部楼层
fsss007 发表于 2020-4-2 09:07
恭喜恭喜,我也有这屏。可以共享吗?

只要你能看懂。
比如说自由矩形填充和Printf用来显示ASCII字符:
  1. FreeSquareFill8x6   PROC
  2.                         EXPORT   FreeSquareFill8x6
  3.                                         PUSH     {R4-R6,R14}
  4.                                         CMP      R0,#0x7A
  5.                                         BHI      FS6InvaildInput
  6. ;The R0 is restricted to 0x7A, for only 128 pixels are contained in one page, any value
  7. ;higher than it will result the maximum X-offset of the prescriptive square area surpasses
  8. ;valid range.
  9.                     CMP      R1,#0x07
  10.                                         BLO      FS6InvaildInput
  11. ;The R1 is restricted to 0x07, for a 8x6 square area can not be contented if the Y coordinate
  12. ;is less than 7.
  13.                     MOVS     R4,#0x07
  14.                                         SUB      R4,R1,LSR#0x03
  15. ;Translate Y-coordinate to page offset value. R4=7-R1/8.
  16.                                         ADD      R0,R4,R0,LSL#0x03
  17. ;Calculate initial offset address whereby the location of the first element concerned can be
  18. ;confirmed.
  19.                     AND      R1,#0x07
  20.                                         ADDS     R1,#0x19
  21. ;Calculate bit offset value defined by Y-coordinate. R1=25+R1%8.
  22.                     LDR      R4,=GraphyBuff
  23. ;Load graphy data head address.
  24.                     CMP      R3,#0x00
  25.                                         MOVNE    R3,#0xFF
  26. ;If R3 is non zero, the content written to graphy buff will be reversed first.
  27.                                         ADDS     R0,R4
  28. ;MOV pointer to the first element of the first page which is to be modified.
  29.                     MVN      R4,#0xFF
  30.                                         RORS     R4,R1
  31. ;Generate bit mask.
  32.                     MOVS     R14,#0x06
  33. FS6SegModifyLoop    LDRB     R5,[R2],#0x01
  34. ;Load a byte from data source and move pointer to next byte.
  35.                     LDR      R6,[R0]
  36. ;Load a word from graphy buff.
  37.                                         EORS     R5,R3
  38. ;Bit reversal.
  39.                     RORS     R5,R1
  40.                                         ANDS     R6,R4
  41.                                         ORRS     R5,R6
  42. ;Mask unconcerned bits and consolidate two data blocks.
  43.                     STR      R5,[R0],#0x08
  44. ;Write back to graphy buff and move pointer to next segment to be modified.
  45.                                         SUBS     R14,#0x01
  46.                                         BNE      FS6SegModifyLoop
  47. ;Fill the buff with given data, stops after finishing all segments.
  48. FS6InvaildInput     POP      {R4-R6,R15}
  49.                         ENDP
  50. ;This function aims to provide a approach that user can fill a appointed 8x6 suqare area
  51. ;without the limit of location.
  52. FreeSquareFill8x8   PROC
  53.                         EXPORT   FreeSquareFill8x8
  54.                                         PUSH     {R4-R6,R14}
  55.                                         CMP      R0,#0x78
  56.                                         BHI      FS8InvaildInput
  57. ;The R0 is restricted to 0x78, for only 128 pixels are contained in one page, any value
  58. ;higher than it will result the maximum X-offset of the prescriptive square area surpasses
  59. ;valid range.
  60.                     CMP      R1,#0x07
  61.                                         BLO      FS8InvaildInput
  62. ;The R1 is restricted to 0x07, for a 8x8 square area can not be contented if the Y coordinate
  63. ;is less than 7.
  64.                     MOVS     R4,#0x07
  65.                                         SUB      R4,R1,LSR#0x03
  66. ;Translate Y-coordinate to page offset value. R4=7-R1/8.
  67.                                         ADD      R0,R4,R0,LSL#0x03
  68. ;Calculate initial offset address whereby the location of the first element concerned can be
  69. ;confirmed.
  70.                     AND      R1,#0x07
  71.                                         ADDS     R1,#0x19
  72. ;Calculate bit offset value defined by Y-coordinate. R1=25+R1%8.
  73.                     LDR      R4,=GraphyBuff
  74. ;Load graphy data head address.
  75.                     CMP      R3,#0x00
  76.                                         MOVNE    R3,#0xFF
  77. ;If R3 is non zero, the content written to graphy buff will be reversed first.
  78.                                         ADDS     R0,R4
  79. ;MOV pointer to the first element of the first page which is to be modified.
  80.                     MVN      R4,#0xFF
  81.                                         RORS     R4,R1
  82. ;Generate bit mask.
  83.                     MOVS     R14,#0x08
  84. FS8SegModifyLoop    LDRB     R5,[R2],#0x01
  85. ;Load a byte from data source and move pointer to next byte.
  86.                     LDR      R6,[R0]
  87. ;Load a word from graphy buff.
  88.                                         EORS     R5,R3
  89. ;Bit reversal.
  90.                     RORS     R5,R1
  91.                                         ANDS     R6,R4
  92.                                         ORRS     R5,R6
  93. ;Mask unconcerned bits and consolidate two data blocks.
  94.                     STR      R5,[R0],#0x08
  95. ;Write back to graphy buff and move pointer to next segment to be modified.
  96.                                         SUBS     R14,#0x01
  97.                                         BNE      FS8SegModifyLoop
  98. ;Fill the buff with given data, stops after finishing all segments.
  99. FS8InvaildInput     POP      {R4-R6,R15}
  100.                         ENDP
  101. ;This function aims to provide a approach that user can fill a appointed 8x8 suqare area
  102. ;without the limit of location.
  103. Printf              PROC
  104.                         EXPORT   Printf
  105.                                         IMPORT   ASCII8x6
  106.                                         PUSH     {R4-R6,R14}
  107.                                         MOVS     R4,R1
  108.                                         MOVS     R5,R2
  109.                                         MOVS     R6,R0
  110.                                         MOVS     R7,R3
  111. ;
  112.                                         LDR      R8,=ASCII8x6
  113. ;
  114.                     B        StartDrawCharacter
  115. DrawCharacter       CBZ      R0,StringEnd
  116. ;
  117.                                         CMP      R0,#0x7E
  118.                                         MOVHI    R0,#0x20
  119.                                         SUBS     R0,#0x20
  120.                                         MOVLO    R0,#0x00
  121. ;
  122.                     MOVS     R1,#0x06
  123.                                         MLA      R2,R0,R1,R8
  124. ;
  125.                     MOVS     R1,R5
  126.                     MOVS     R0,R4
  127. ;
  128.                                         MOVS     R3,R7
  129. ;
  130.                     BL       FreeSquareFill8x6
  131. ;
  132. StartDrawCharacter  LDRB     R0,[R6],#0x01
  133. ;
  134.                                         ADDS     R4,#0x06
  135. ;
  136.                     B        DrawCharacter
  137. StringEnd               POP      {R4-R6,R15}
  138.                         ENDP
复制代码



回复 支持 反对

使用道具 举报

发表于 2020-4-2 09:50:33 | 显示全部楼层
看不懂,没办法用。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-4-2 10:07:49 | 显示全部楼层
本帖最后由 la45088d1 于 2020-4-2 10:09 编辑
fsss007 发表于 2020-4-2 09:50
看不懂,没办法用。

我记得SSD1309,1306都被人玩烂了!
现在网上一大堆例程,你找不到吗?
比如说正点原子也有一些测试例程,还有这个12864 OLDE的模块供应商也有资料呀?
给你一份吧:
这里面用的就是最大众化的页面寻址方式,不像我搞骚套路,应该是很容易的了。里面有些文件是前天刚从供货商那里要的,绝对权威,虽然对我帮助有限就是了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

打赏

参与人数 1家元 +20 收起 理由
kkdkj + 20 謝謝分享

查看全部打赏

回复 支持 反对

使用道具 举报

发表于 2020-4-2 10:48:28 | 显示全部楼层
la45088d1 发表于 2020-4-2 10:07
我记得SSD1309,1306都被人玩烂了!
现在网上一大堆例程,你找不到吗?
比如说正点原子也有一些测试例程, ...

谢谢楼主。玩不转就先让其吃灰。
回复 支持 反对

使用道具 举报

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

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2025-5-20 01:12 , Processed in 0.312000 second(s), 13 queries , Redis On.

Powered by Discuz!

© 2006-2025 MyDigit.Net

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