From 4762e8fb4ed51516c4f3e66f7727a21a8b365dcd Mon Sep 17 00:00:00 2001 From: Bjoern Date: Sun, 19 Mar 2023 17:17:15 +0000 Subject: [PATCH 1/3] Create ieq.py --- badger_os/examples/ieq.py | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 badger_os/examples/ieq.py diff --git a/badger_os/examples/ieq.py b/badger_os/examples/ieq.py new file mode 100644 index 0000000..5c4b19b --- /dev/null +++ b/badger_os/examples/ieq.py @@ -0,0 +1,54 @@ +import time +import badger2040 +import badger_os +from breakout_bme68x import BreakoutBME68X +import pimoroni_i2c + +# Display Setup +display = badger2040.Badger2040() +display.led(128) +display.set_update_speed(2) + +WIDTH = badger2040.WIDTH +HEIGHT = badger2040.HEIGHT + +PINS_PICO_EXPLORER = {"sda": 4, "scl": 5} + +i2c = pimoroni_i2c.PimoroniI2C(**PINS_PICO_EXPLORER) +#bme = BreakoutBME68X(i2c,0x77) +bme = BreakoutBME68X(i2c) + +def draw_values(t,h,p): + + # Clear the display + display.set_pen(15) + display.clear() + display.set_pen(0) + display.set_font("sans") + + # Draw the page header + display.set_pen(15) + display.rectangle(0, 0, WIDTH, 20) + display.set_pen(0) + y=10 + display.text("IEQ", 0, 10, y, 0.5) + scale=100 + n=1 + offset=30 + display.text("T="+t+" C", 0 , y+offset, scale, n) + display.text("h="+h+" %", 0 , y+offset*2, scale, n) + display.text("p="+p+" hPa", 0 , y+offset*3, scale, n) + display.update() + + + +while True: + temperature, pressure, humidity, gas, status, _, _ = bme.read() + heater = "Stable" if status else "Unstable" # & STATUS_HEATER_STABLE + #print("{:0.2f}c, {:0.2f}Pa, {:0.2f}%, {:0.2f} Ohms, Heater: {}".format( + # temperature, pressure, humidity, gas, heater)) + temp = str(round(temperature,1)) + press = str(round(pressure/100,1)) + humid = str(round(humidity,1)) + draw_values(temp, humid, press) + time.sleep(10.0) From b1c46c8cbd60c1dddcb461fff121ff635f4cafea Mon Sep 17 00:00:00 2001 From: Bjoern Date: Sun, 19 Mar 2023 17:17:56 +0000 Subject: [PATCH 2/3] Add files via upload --- badger_os/examples/icon-ieq.jpg | Bin 0 -> 1591 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 badger_os/examples/icon-ieq.jpg diff --git a/badger_os/examples/icon-ieq.jpg b/badger_os/examples/icon-ieq.jpg new file mode 100644 index 0000000000000000000000000000000000000000..35d3bd0032c2eb93c546df0261b2804873149b99 GIT binary patch literal 1591 zcmb79Ydq5n82Wt2EO>wG%rd^^wketO>LeV^x*zLib@XeURCBLIRR;3F$Q z`VO!Mpb*H9mO)O|Fa;P)P7a2E!{rrF2ows5Kq8ftv1lb_j4~35RzqV{ad06+mK2>b&I ziZFRNLN+6y0f@{N0?Nt4|1AI^viS0F1q>EYRm7=j>*96v%*=P#$;9{{FaH}58I8mI zmj$Gw07~Wv!9X#9El_bP)FYx}f%$@bhPy(rD9T{6<6Q5SFLq$p>z(5uEfMAO#aFr~ zRDaV(E}s?Kan58u{$Q*=H8goXtgv;sBcwdXo=R8o#uPMo{y8}3y|EFzxH)!{wSIjn zbJ*Fle=)|8rTZkBaNgq7FPxPdNnJJ^jSz`b`@%JyS0%^B%q^*c{qu&71xX_wg2v+t zJ0i>{bEg?vUN-!1+T|_2Ie5))0pgcVo)1Fy`ymYouL7zAYlSKUq3-!tnOv*5q9p2M zuHOP8EV$;p|4)ucs(Y`F7?C%nvNWqM`8;{pjC4m(7{rgr?xjhZnO!(b#D-gRvM9|H z>$v7C?@vpeOwqm71LyU9RXo}!;s&YzIbyzQ)UMOg@$0y4_RjBG_boy`H!V0ZB+A}F zGtQQ?M^qc)=H904UH289k_b=rJ!iX{Ol-%!T3zS#<@?mfft+{R*Kz`)sLRcD;mx?0 zik*+1Ribih!>Br0fw~QB|Gig6kB?Z+&@^5Myj@Q=^Pl7qo3382t{YV4gyd>aP}SvV zUXGnyqGp(6*{kNX6sXP*Eq?!Lkv2{^D0CLkg~e{VY07;UwBBIJTIY&eT)M@sse`Lf zUgXYzy3x7bVL$QgvoF+&(Le^9U}Vx18@XXj2WwU6;cDVV3*NsKd+@-88x>}C`W!|= zeSIN)&xws{6~da5;op7Yk{(C_yo-+)cWXv~M^V2Ae469FDAB&))rZdPEP4*^oY%}M zO)48(YA=f&JsXg=CZyQYNlPoYruZ!3k*nz_jeSJ66ks~*#|I@x1@Nd7VaeL>NImiI zs}hnjkY}xheAgHb_a6V9;m^1cW8KE~?pEg4^fLdw;F>>iwiTbN3p3%B`mA4&qzUB< z=}oM-H-pV5A7%%!ka_wUB_G^iwr$0`r9hOXK#6$ZJ%q5o59`H?))%TKBWoPOk716U zQAalxJGfsNlmh;8=r<&lm`52SXR?_E!sE$)aomqqC7EiqKBo=9Ert{J>xI}Qk}^f_ zp4rjRAoaWXqVVpys6OwiLMK6AL0pN_T4DPN zYrP-Krx+0r118a)JEul4RhIuL3W&D#P=H|hg))u`ztI&?kn=S$KD!{yc zd;gtj?cpp_XPx>(o_2Xtb>++ObUi!QW1?xEQ*~M6kVBARCktI@<=^9lHO@$Fk0xw4Xltw5%XVr(mF^(SXFN~DHb$ud)zJDyttd^x=99FUr9ihOEW(&pSh-sC%GG9DK4 sWSkOJ!NJ8!OyPHLr*Ado_MD|shb0D|DK5V4`Z?U);DjbPkt`Mb1%MZyBme*a literal 0 HcmV?d00001 From 90820d54a7a0dc1d4103004447f46a3c5cec75c8 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Sun, 19 Mar 2023 17:18:52 +0000 Subject: [PATCH 3/3] Update qrgen.py --- badger_os/examples/qrgen.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/badger_os/examples/qrgen.py b/badger_os/examples/qrgen.py index f1d7ff8..0814c50 100644 --- a/badger_os/examples/qrgen.py +++ b/badger_os/examples/qrgen.py @@ -3,6 +3,7 @@ import time import os import badger_os +import re # Check that the qrcodes directory exists, if not, make it try: @@ -76,6 +77,9 @@ def draw_qr_file(n): code_text = lines.pop(0) title_text = lines.pop(0) detail_text = lines + # For vcards to work, we need to be able to insert new lines. Use
as new line character: + code_text = re.sub("
","\n",code_text) + # Clear the Display display.set_pen(15) # Change this to 0 if a white background is used @@ -117,11 +121,17 @@ def draw_qr_file(n): if state["current_qr"] > 0: state["current_qr"] -= 1 changed = True + else: + state["current_qr"] = TOTAL_CODES - 1 + changed = True if display.pressed(badger2040.BUTTON_DOWN): if state["current_qr"] < TOTAL_CODES - 1: state["current_qr"] += 1 changed = True + else: + state["current_qr"] = 0 + changed = True if display.pressed(badger2040.BUTTON_B) or display.pressed(badger2040.BUTTON_C): display.set_pen(15)