Skip to content

Commit 2454028

Browse files
committed
going for v0.3.0
1 parent 18cbb45 commit 2454028

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# DumbDisplay MicroPython Library (v0.2.1) #
1+
# DumbDisplay MicroPython Library (v0.2.2) #
22

33
DumbDisplay MicroPython Library is a port of the Arduino DumbDisplay Library (https://github.com/trevorwslee/Arduino-DumbDisplay)
44
for the DumbDisplay Android app -- https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay
55

6-
For a video introduction, please watch the YouTube video: Introducing DumbDisplay MicroPython Library -- with ESP32, Raspberry Pi Pico, and Raspberry Pi Zero -- https://www.youtube.com/watch?v=KVU26FyXs5M
6+
For a video introduction, please watch the YouTube video: Introducing DumbDisplay MicroPython Library --
7+
with ESP32, Raspberry Pi Pico, and Raspberry Pi Zero -- https://www.youtube.com/watch?v=KVU26FyXs5M
78

8-
Although the porting is not complete, nevertheless, a large portion of DumbDisplay functionalities have been ported. Hopefully, this should already be helpful for friends that develop programs for micro-controller boards in Micro-Python.
9+
Although the porting is not complete, nevertheless, a large portion of DumbDisplay functionalities have been ported.
10+
Hopefully, this should already be helpful for friends that develop programs for microcontroller boards in Micro-Python.
911

1012
Note that even it is targeted for MicroPython, it is still usable with regular Python 3, like in Raspberry Pi environment,
1113
or even with desktop / laptop.
@@ -114,7 +116,7 @@ Notes:
114116
import machine
115117
machine.reset_cause()
116118
```
117-
* If DumbDisplay Android app fails to make connection to desktop / laptopo, check your descktop firewall settings; try switching desktop WIFI to use 2.4 GHz.
119+
* If DumbDisplay Android app fails to make connection to desktop / laptop, check your desktop firewall settings; try switching desktop WIFI to use 2.4 GHz.
118120
119121
120122
@@ -124,6 +126,10 @@ Notes:
124126
125127
# Change History
126128
129+
v0.3.0
130+
- checked Raspberry Pi Pico W WIFI support
131+
- port more options from Arduino DumbDisplay library
132+
- bug fixes
127133
128134
v0.2.1
129135
- add plotter layer

samples/melody/main.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
from dumbdisplay.layer_graphical import LayerGraphical
44
from dumbdisplay.layer_lcd import LayerLcd
55

6+
try:
7+
from .piohwtone import HWPlayTone
8+
except:
9+
HWPlayTone = None
610

7-
song = "G C E C E D C A G G C E C E D G E G E G E C G A C C A G G C E C E D C Z"
8-
octave = "0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 Z"
9-
beat = "2 4 1 1 4 2 4 2 4 2 4 1 1 4 2 8 2 1 1 1 1 4 2 4 1 1 1 4 2 4 1 1 4 2 8 Z"
11+
Song = "G C E C E D C A G G C E C E D G E G E G E C G A C C A G G C E C E D C Z"
12+
Octave = "0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 Z"
13+
Beat = "2 4 1 1 4 2 4 2 4 2 4 1 1 4 2 8 2 1 1 1 1 4 2 4 1 1 1 4 2 4 1 1 4 2 8 Z"
1014

11-
beatSpeed = 300
15+
BeatSpeed = 300
1216

1317
TOP_HEIGHT = 30
1418
WIDTH = 14
@@ -62,16 +66,13 @@ def GetNoteFreq(octave, noteIdx):
6266
return int(freq + 0.5)
6367

6468

65-
66-
def PlayTone(freq, duration, playToSpeaker: bool):
67-
# #ifdef SPEAKER_PIN
68-
# if (playToSpeaker) {
69-
# PlayTone(freq, duration);
70-
# return;
71-
# }
72-
# #endif
73-
dd.tone(freq, duration)
74-
dd.delay_ms(duration)
69+
def PlayTone(freq: int, duration: int, playToSpeaker: bool):
70+
if playToSpeaker:
71+
if HWPlayTone:
72+
HWPlayTone(freq, duration)
73+
else:
74+
dd.tone(freq, duration)
75+
dd.delay_ms(duration)
7576

7677

7778
def FeedbackHandler(layer, type, x, y):
@@ -119,19 +120,19 @@ def run(self):
119120
break
120121
if not self.play:
121122
continue
122-
noteName = song[i]
123+
noteName = Song[i]
123124
if noteName == "Z":
124125
# reached end of song => break out of loop
125126
break
126127

127-
halfNote = song[i + 1]
128+
halfNote = Song[i + 1]
128129

129130
# convert the song note into tone frequency
130131
noteIdx = ToNoteIdx(noteName, halfNote)
131-
freq = GetNoteFreq(ord(octave[i]) - ord('0'), noteIdx)
132+
freq = GetNoteFreq(ord(Octave[i]) - ord('0'), noteIdx)
132133

133134
# get the how to to play the note/tone for
134-
duration = beatSpeed * (ord(beat[i]) - ord('0'))
135+
duration = BeatSpeed * (ord(Beat[i]) - ord('0'))
135136

136137
# play the note/tone
137138
PlayTone(freq, duration, self.playToSpeaker)
@@ -155,19 +156,13 @@ def setupKey(self, octaveOffset: int, noteIdx: int) -> LayerGraphical:
155156
bgColor = "white"
156157
if noteIdx > 4:
157158
xOffset += WIDTH / 2
158-
#customData = chr(ord(" ") + octiveOffset) + chr(ord(" ") + noteIdx)
159-
#customData[0] = '0' + octiveOffset;
160-
#customData[1] = '0' + noteIdx;
161-
#customData[2] = 0;
162159
keyLayer = LayerGraphical(dd, width, height)
163160
keyLayer.octaveOffset = octaveOffset
164161
keyLayer.noteIdx = noteIdx
165-
#keyLayer.customData = customData
166162
keyLayer.backgroundColor(bgColor)
167163
keyLayer.border(BORDER, "gray")
168164
keyLayer.padding(0)
169165
keyLayer.enableFeedback("fa", FeedbackHandler)
170-
#keyLayer->setFeedbackHandler(FeedbackHandler, "f");
171166
if isSemi:
172167
keyLayer.reorderLayer("T")
173168
pass

samples/melody/piohwtone.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import time
2+
import rp2
3+
from machine import Pin
4+
5+
6+
def HWPlayTone(freq: int, duration: int):
7+
pass

0 commit comments

Comments
 (0)