Skip to content

Instantly share code, notes, and snippets.

View Staars's full-sized avatar

Christian Baars Staars

View GitHub Profile
@Staars
Staars / python2berrry.js
Created July 6, 2024 16:24
test script for the docs
class Transpiler {
code;
output;
preventTerminationWords = ["else","elif","except"];
needTerminationWords = ["if","class","def","while","for","try"];
opening =["(","{","["];
closing =[")","}","]"];
multiline;
@Staars
Staars / cam_demo.be
Created May 31, 2024 11:59
cam snippet Berry
lv.start()
# set background color to blue
scr = lv.scr_act()
scr.set_style_bg_color(lv.color(lv.COLOR_BLUE), lv.PART_MAIN | lv.STATE_DEFAULT)
# create a lv_img object and set it to Tasmota logo
logo = lv.img(scr)
logo.set_tasmota_logo()
logo.center()
@Staars
Staars / wc.be
Last active June 22, 2024 10:22
Test webcam
class WC
def init()
import cam
cam.setup(7)
self.web_add_handler()
tasmota.add_driver(self)
end
@Staars
Staars / opus_test.py
Last active February 22, 2024 13:21
pyogg opus test
# Convert raw data from Alexa remote control - Bluetooth
import wave
from pyogg import OpusDecoder
if __name__ == "__main__":
# Setup decoding
# ==============
# Create an Opus decoder
opus_decoder = OpusDecoder()
@Staars
Staars / bpr2s_voice.be
Created January 23, 2024 20:17
bpr2s voice test
# Simple Berry driver for the BPR2S Air mouse (a cheap BLE HID controller)
import BLE
class ADPCM
static indexTable = [
-1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8
]
@Staars
Staars / chromecast_ble.be
Last active August 25, 2024 23:10
Chromecast remote control
# Simple Berry driver for the Chromecast remote - VERY UNFINISHED
# DOES NOT REALLY WORK - RC disconnects after short time!!!!!
import BLE
var hid
class HID
static hid_service = "1812"
var hid_chars
@Staars
Staars / BPR2S_voice.be
Created January 20, 2024 08:26
BPR2S Air mouse with mic input
# Simple Berry driver for the BPR2S Air mouse (a cheap BLE HID controller)
import BLE
class ADPCM
static indexTable = [
-1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8
]
@Staars
Staars / tamp.patch
Created January 15, 2024 19:17
Some compression tests
diff --git a/lib/default/tamp/library.properties b/lib/default/tamp/library.properties
new file mode 100644
index 000000000..c4bb469cd
--- /dev/null
+++ b/lib/default/tamp/library.properties
@@ -0,0 +1,7 @@
+name=Tamp
+version=1.0
+author=
+maintainer=
@Staars
Staars / adpcm.be
Created January 4, 2024 13:14
Berry ADPCM decoder
# Berry class to decode ADPCM sample
# ADPCM decoder implementation based on https://github.com/jwzhangjie/Adpcm_Pcm/blob/master/adpcm.c
class ADPCM
static indexTable = [
-1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8
]
@Staars
Staars / ble_daydream.be
Created January 3, 2024 14:10
Daydream Controller Berry
# Simple Berry driver for the Google Daydream controller
import BLE
class BLE_DAYD : Driver
var buf
var connecting, connected, new_position
var time,seq,xO,yO,zO,xA,yA,zA,xG,yG,zG,xT,yT,button
def init(MAC,addr_type)