adafruit lcd_在AdaFruit PyPortal上显示NightScout的实时血糖

adafruit lcd

adafruit lcd

for the kids - and me. It a little dakBoard, if you will - a tiny totally programmable display with Wi-Fi and  lots of possibilities and sensors. Even better, you can just plug it in over USB and edit the file directly on the drive that will appear. When you save the device soft reboots and runs your code.

为孩子们-还有我如果您愿意的,它有点像dakBoard-带有Wi-Fi并带有多种可能性和传感器的完全可编程的微型显示屏。 更好的是,您只需将其插入USB并直接在将出现的驱动器上编辑code.py文件。 保存code.py时,设备将重新启动并运行您的代码。

I've been using Visual Studio Code to program Circuit Python and it's become my most favorite IoT experience so far because it's just so easy. The "Developer's Inner Loop" of code, deploy, debug is so fast.

我一直在使用Visual Studio Code对Circuit Python进行编程,由于它是如此简单,所以它成为了我迄今为止最喜欢的IoT体验。 代码,部署,调试的“开发人员内部循环”是如此之快。

As you may know, I use a Dexcom CGM (Continuous Glucose Meter) to manage my Type 1 Diabetes. I feed the data every 5 minutes into an instance of the Nightscout Open Source software hosted in Azure. That gives me a REST API to my own body.

如您所知,我使用Dexcom CGM(连续血糖仪)来管理1型糖尿病。 我每5分钟将数据送入Azure托管的Nightscout开源软件实例中。 这给了我自己身体的REST API。

I use that REST API to make "glanceable displays" where I - or my family - can see my blood sugar quickly and easily.

我使用REST API进行“可视显示”,以便我(或我的家人)可以快速,轻松地看到我的血糖。

I put my blood sugar in places like:


And today, on a tiny PyPortal device. The code is simple, noting that I don't speak Python, so Pull Requests are always appreciated.

今天,在小型PyPortal设备上。 代码很简单,并指出我不会说Python,因此始终对Pull Requests表示赞赏。

import time
import board
from adafruit_pyportal import PyPortal

# Set up where we'll be fetching data from
DATA_SOURCE = "https://NIGHTSCOUTWEBSITE/api/v1/entries.json?count=1"
BG_VALUE = [0, 'sgv']
BG_DIRECTION = [0, 'direction']

RED = 0xFF0000;
ORANGE = 0xFFA500;
GREEN = 0x00FF00;

def get_bg_color(val):
if val > 200:
return RED
elif val > 150:
return YELLOW
elif val < 60:
return RED
elif val < 80:
return ORANGE
return GREEN

def text_transform_bg(val):
return str(val) + ' mg/dl'

def text_transform_direction(val):
if val == "Flat":
return "→"
if val == "SingleUp":
return "↑"
if val == "DoubleUp":
return "↑↑"
if val == "DoubleDown":
return "↓↓"
if val == "SingleDown":
return "↓"
if val == "FortyFiveDown":
return "→↓"
if val == "FortyFiveUp":
return "→↑"
return val

# the current working directory (where this file is)
cwd = ("/"+__file__).rsplit('/', 1)[0]
pyportal = PyPortal(url=DATA_SOURCE,
text_position=((90, 120), # VALUE location
(140, 160)), # DIRECTION location
text_color=(0x000000, # sugar text color
0x000000), # direction text color
text_wrap=(35, # characters to wrap for sugar
0), # no wrap for direction
text_maxlen=(180, 30), # max text size for sugar & direction

# speed up projects with lots of text by preloading the font!
pyportal.preload_font((0x2191, 0x2192, 0x2193))

while True:
value = pyportal.fetch()
print("Response is", value)
except RuntimeError as e:
print("Some error occured, retrying! -", e)

I've put the code up at I want to get (make a custom?) a larger BDF (Bitmap Font) that is about twice the size AND includes 45 degree arrows ↗ and ↘ as the font I have is just 24 point and only includes arrows at 90 degrees. Still, great fun and took just an hour!

我将代码放在上。 我想获得一个较大的BDF(位图字体),它的大小大约是它的两倍,并且包括45度箭头↗和↘,因为我的字体只有24点并且仅包括90度的箭头。 仍然非常有趣,只花了一个小时!

NOTE: I used the Chortkeh BDF Font viewer to look at the Bitmap Fonts on Windows. I still need to find a larger 48+ PT Arial.

注意:我使用Chortkeh BDF字体查看器查看Windows上的位图字体。 我仍然需要找到更大的48+ PT Arial。

What information would YOU display on a PyPortal?


Sponsor: Manage GitHub Pull Requests right from the IDE with the latest JetBrains Rider. An integrated performance profiler on Windows comes to the rescue as well.

赞助商:使用最新的JetBrains Rider从IDE直接管理GitHub Pull Requests。 Windows上的集成性能分析器也可以解决。


adafruit lcd


  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
钱包余额 0