def GLCDBox(Xp0, Yp0, Xp1, Yp1):
for i in range(Xp0, Xp1 + 1):
GLCDPutPixel(i, Yp0)
GLCDPutPixel(i, Yp1)
for i in range(Yp0 + 1, Yp1):
GLCDPutPixel(Xp0, i)
GLCDPutPixel(Xp1, i)
def GLCDPutPixel(Xp, Yp):
#ラインの選択処理
L = 1 << (Yp % 8)
#LCDに表示するアドレスの位置をセットする
SetLocation(Xp, Yp)
#LCD画面の現在表示内容に指定位置のビット(L)をON(XOR)させ、そのデータをLCDに送る
L = ReadData() | L
SetAddress(SetCol)
WriteData(L)
def ReadData():
#データピンを入力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.IN)
#読み込みモードにする
GPIO.output(RW_p, GPIO.HIGH)
GPIO.output(RS_p, GPIO.HIGH)
#データを読み込む
GPIO.output(E_p, GPIO.HIGH)
GPIO.output(E_p, GPIO.LOW)
ans = 0
GPIO.output(E_p, GPIO.HIGH)
for i in range(8):
ans = ans | (GPIO.input(DATA_p[i]) << i)
GPIO.output(E_p, GPIO.LOW)
#書き込みモードにする
GPIO.output(RW_p, GPIO.LOW)
#データピンを出力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.OUT)
return ans
def ReadData():
#データピンを入力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.IN)
#読み込みモードにする
GPIO.output(RW_p, GPIO.HIGH)
GPIO.output(RS_p, GPIO.HIGH)
#データを読み込む
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
GPIO.output(E_p, GPIO.LOW)
ans = 0
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
for i in range(8):
ans = ans | (GPIO.input(DATA_p[i]) << i)
GPIO.output(E_p, GPIO.LOW)
#書き込みモードにする
GPIO.output(RW_p, GPIO.LOW)
#データピンを出力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.OUT)
return ans
def command(value, mode):
GPIO.output(RS_p, mode)
for i in range(8):
GPIO.output(DATA_p[i], (value >> i) & 0x01)
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
GPIO.output(E_p, GPIO.LOW)
Sub output()
Dim TownArea As Object
Dim Rows As Integer
Set TownArea = Worksheets("Sheet1").Range("AU1", Range("AU1").End(xlDown).End(xlToRight))
Rows = TownArea.Rows.Count
Dim Area As Object
Dim RightLength As Integer
Dim DownLength As Integer
Set Area = Worksheets("Sheet1").Range("B2:AS36")
RightLength = Area.Columns.Count
DownLength = Area.Rows.Count
Dim WS2 As Object
Set WS2 = Worksheets("Sheet2")
Dim WriteLine As Integer
WriteLine = 1
WS2.Cells(WriteLine, 1).Value = "{""list"":["
WriteLine = WriteLine + 1
For R = 1 To Rows
Dim number As Integer
Dim name As String
number = TownArea.Cells(R, 1).Value
name = TownArea.Cells(R, 2).Value
WS2.Cells(WriteLine, 2).Value = "{""name"" :"""
WS2.Cells(WriteLine, 3).Value = name
WS2.Cells(WriteLine, 4).Value = """, ""point"" :["
For RL = 1 To RightLength
For DL = 1 To DownLength
If Area.Cells(RL, DL).Value = number Then
WS2.Cells(WriteLine, 5).Value = "{""x"" :"
WS2.Cells(WriteLine, 6).Value = RL - 1
WS2.Cells(WriteLine, 7).Value = ", ""y"" :"
WS2.Cells(WriteLine, 8).Value = DL - 1
WS2.Cells(WriteLine, 9).Value = "}"
WS2.Cells(WriteLine, 10).Value = ","
WriteLine = WriteLine + 1
End If
Next
Next
WS2.Cells(WriteLine - 1, 10).Value = "]},"
Next
WS2.Cells(WriteLine - 1, 10).Value = "]}"
WS2.Cells(WriteLine, 1).Value = "]}"
End Sub