HaaS征文上新开源HaaS100扩展板
Posted HaaS技术社区
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HaaS征文上新开源HaaS100扩展板相关的知识,希望对你有一定的参考价值。
板载硬件资源:
- 24V转12V模块接口 x1
- 12V非隔离开关 x1
- 24V非隔离开关 x1
- 12V/24V可选的隔离继电器 x1
- 兼容SPI和I2C的OLED接口 x1
- 3.5mm音频接口 x1
- 微动按键 x3
- 5.5mmx2.1mm DC接口 x1
- 自恢复保险丝 x1
- 接线柱 x2
- PH2.54插座 x3
注:实物Rev1.2 丝印SCL(I2C)和CLK(SPI)位置错误,应该互换。(项目文件已修复此问题)
正确丝印如下:
注:使用SPI0接口,只需短接CLK和MOSI两处即可。使用I2C需要短接SCL和SDA并焊接I2C上拉电阻R12/R13。
完整PCB预览
下图是使用SPI0点亮OLED的演示:
如题所示,项目软硬件全部开源,请遵循GPL 3.0协议。
#!/usr/bin/env python
# -*- coding:utf-8 -*-
###
# Filename: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled/main.py
# Path: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled
# Created Date: Tuesday, October 26th 2021, 11:33:39 am
# Author: Simon Liu
#
# Copyright (C) <2021> <刘知海> <toopoo@gmail.com> GPLv3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
###
# -*- coding: UTF-8 -*-
import time
from driver import SPI
from driver import GPIO
import sh1106
# OLED屏幕实例
oled = None
def oled_init():
oled_spi = SPI()
oled_spi.open("SPI0")
oled_res = GPIO()
oled_res.open("oled_res")
oled_dc = GPIO()
oled_dc.open("oled_dc")
global oled
oled = sh1106.SH1106_SPI(128, 64, oled_spi, oled_dc, oled_res)
def hello():
global oled
oled.fill(0)
oled.text(' Hello HaaS100!', 2, 16, 1)
oled.text(' Simon Liu', 2, 32, 1)
oled.show()
def main():
print("---=== OLED example ===---")
oled_init()
hello()
if __name__ == '__main__':
main()
注意要配合board.json文件
{
"name": "haas100",
"version": "1.0.0",
"io": {
"ADC0": {
"type": "ADC",
"port": 0,
"sampling": 12000000
},
"oled_i2c": {
"type": "I2C",
"port": 2,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 120
},
"pca9544": {
"type": "I2C",
"port": 1,
"addrWidth": 8,
"freq": 100000,
"mode": "master",
"devAddr": 112
},
"mpu6050": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 100000,
"mode": "master",
"devAddr": 105
},
"ap3216c": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 100000,
"mode": "master",
"devAddr": 30
},
"si7006": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 64
},
"spl06": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 119
},
"qmc5883": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 13
},
"KEY1": {
"type": "GPIO",
"port": 21,
"dir": "irq",
"pull": "opendrain",
"intMode": "falling"
},
"KEY2": {
"type": "GPIO",
"port": 20,
"dir": "irq",
"pull": "opendrain",
"intMode": "falling"
},
"KEY3": {
"type": "GPIO",
"port": 39,
"dir": "irq",
"pull": "opendrain",
"intMode": "falling"
},
"CTRL1": {
"type": "GPIO",
"port": 22,
"dir": "output",
"pull": "pullup"
},
"CTRL2": {
"type": "GPIO",
"port": 38,
"dir": "output",
"pull": "pullup"
},
"CTRL3": {
"type": "GPIO",
"port": 23,
"dir": "output",
"pull": "pullup"
},
"led1": {
"type": "GPIO",
"port": 34,
"dir": "output",
"pull": "pullup"
},
"led2": {
"type": "GPIO",
"port": 35,
"dir": "output",
"pull": "pullup"
},
"led3": {
"type": "GPIO",
"port": 36,
"dir": "output",
"pull": "pullup"
},
"led_r": {
"type": "GPIO",
"port": 36,
"dir": "output",
"pull": "pullup"
},
"led_g": {
"type": "GPIO",
"port": 35,
"dir": "output",
"pull": "pullup"
},
"led_b": {
"type": "GPIO",
"port": 34,
"dir": "output",
"pull": "pullup"
},
"SPI0": {
"type": "SPI",
"port": 0,
"mode": "master",
"freq": 2000000
},
"oled_dc": {
"type": "GPIO",
"port": 33,
"dir": "output",
"pull": "pullup"
},
"oled_res": {
"type": "GPIO",
"port": 32,
"dir": "output",
"pull": "pullup"
},
"serial1": {
"type": "UART",
"port": 0,
"dataWidth": 8,
"baudRate": 9600,
"stopBits": 1,
"flowControl": "disable",
"parity": "none"
},
"port485": {
"type": "UART",
"port": 1,
"dataWidth": 8,
"baudRate": 38400,
"stopBits": 1,
"flowControl": "disable",
"parity": "none"
},
"serial2": {
"type": "UART",
"port": 2,
"dataWidth": 8,
"baudRate": 115200,
"stopBits": 1,
"flowControl": "disable",
"parity": "none"
}
},
"debugLevel": "ERROR",
"repl": "disable"
}
开源地址:
以上是关于HaaS征文上新开源HaaS100扩展板的主要内容,如果未能解决你的问题,请参考以下文章
AliOS Things 3.3.0 : 实战HaaS100扩展SD卡
HaaS100开发调试系列 之 定位AliOS Things内存及Crash问题
HaaS轻应用(JavaScript)快速开始 @HaaS100