Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
豊四季Tiny BASIC OLED(SSD1306 I2C)の表示制御 横表示バージョン
1 'SSD1306_2(PB6=SCL,PB7=SDA)
10 M=MEM:A=$3C:CLS
20 GOSUB "@INIT":GOSUB "@CLS"
30 X=0:Y=0:C=ASC("A"):GOSUB "@OUT(X,Y,C)"
40 X=1:Y=1:C=ASC("B"):GOSUB "@OUT(X,Y,C)"
50 X=2:Y=2:C=ASC("C"):GOSUB "@OUT(X,Y,C)"
60 X=0:Y=5:S="Hello Tiny BASIC":GOSUB "@PRN(X,Y,S)"
70 'WAIT 2000
80 'GOSUB "@CLS"
90 GETTIME E,F,G
100 LOCATE 0,0:?#-2,E;":";F;":";G
110 X=0:Y=7
120 FOR b=0 TO 7
130 C=VPEEK(X,0)
140 GOSUB "@OUT(X,Y,C)"
150 X=X+1
160 NEXT b
170 WAIT 1000
180 GOTO 90
190 END
5000 "@INIT"
5010 POKE M,$00,$B0,$21,$00,$7F,$40,$80
5020 POKE M+7,$AE,$A8,$3F,$D3,$00,$40,$A1,$C8
5030 POKE M+15,$DA,$12,$81,$FF,$A4,$A6,$D5,$80
5040 POKE M+23,$2E,$20,$10,$21,$00,$7F,$22,$00
5050 POKE M+31,$07,$8D,$14,$AF
5060 FOR I=0 TO 27:R=I2CW(A,M,1,M+7+I,1):NEXT I
5070 RETURN
5080 "@OUT(X,Y,C)"
5090 POKE M+3,X*8:POKE M+1,Y|$B0
5100 GOSUB "@ROTATE(C)"
5110 R=I2CW(A,M,1,M+1,4)
5120 R=I2CW(A,M+5,1,M+50,8)
5130 RETURN
5140 "@CLS"
5150 POKE M+3,0:POKE M+1,0|$B0
5160 R=I2CW(A,M,1,M+1,4)
5170 FOR I=0 TO 127
5180 R=I2CW(A,M+5,1,FNT,8)
5190 NEXT I
5200 RETURN
5210 "@PRN(X,Y,S)"
5220 L=LEN(S)
5230 FOR I=1 TO L
5240 C=ASC(S,I)
5250 GOSUB "@OUT(X,Y,C)"
5260 X=X+1:IF X>15 X=0:Y=Y+1
5270 NEXT I
5280 RETURN
5290 "@ROTATE(C)"
5300 F=FNT+C*8
5310 FOR J=0 TO 7
5320 D=0
5330 FOR K=7 TO 0 STEP -1
5340 D=D+((PEEK(F+K)>>(7-J))&1)<<K
5350 NEXT K
5360 POKE (M+50+J),D
5370 NEXT J
5380 RETURN
Owner

Tamakichi commented Jun 21, 2017

OLED SSD1306(I2C)の制御サンプルプログラム
文字の回転に1文字あたり、5ミリ秒かかります。全画面表示(128文字表示)に657ミリ秒かかります。
縦向きバージョンでは全画面表示は78ミリ秒でした。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment