Skip to content

Instantly share code, notes, and snippets.

View teddokano's full-sized avatar

Tedd OKANO teddokano

View GitHub Profile
@teddokano
teddokano / zprintf_making_table.ino
Created August 17, 2023 19:21
zprintf sample code
void zprintf(const char *format, ...);
#define COLS 8
#define ROWS (128 / 8)
void setup() {
Serial.begin(9600);
while (!Serial)
;
@teddokano
teddokano / AE_AQM0802.py
Last active August 4, 2023 01:37
A character LCD: "AE_AQM0802" MicroPython operation sample
from machine import Pin, I2C
import utime
import ure
class AE_AQM0802:
DEFAULT_ADDR = (0x7C >> 1)
def __init__( self, i2c ):
self.i2c = i2c
@teddokano
teddokano / envled_9955b.py
Last active July 8, 2023 08:58
PCA9955B control by audio envelope
from machine import Pin, ADC, Timer
import utime
import sys
from machine import I2C
from nxp_periph import PCA9955B, LED, PCA9629A
if "MicroPython v1.19" in sys.version:
TIMER_ID = 0
else:
@teddokano
teddokano / Arduino_UNO_R4_SPI_test.ino
Created June 28, 2023 07:38
SPI test code for Arduino UNO R4
#include <SPI.h>
SPISettings spi_setting(1000000, MSBFIRST, SPI_MODE0);
void setup() {
Serial.begin(9600);
while (!Serial)
;
SPI.begin();
@teddokano
teddokano / envled.py
Last active June 15, 2023 10:01
Simple LED brightness control (via PCA9956)l by music envelope
from machine import Pin, ADC, Timer
import utime
from machine import I2C
from nxp_periph import PCA9956B, LED
class periodic_adc:
def __init__( self, pin_name, *, interval = 1, scaling = (2 ** 16) ):
self.timer_flag = False
self.adc = ADC( Pin( pin_name ) )
@teddokano
teddokano / MPL3115A2S_measure.py
Created June 11, 2023 03:16
Pressure sensor comparison: MPL115A1 and MPL3115A2S
from machine import I2C, SPI, Pin, Timer
from utime import sleep, localtime
from struct import unpack
import os
class MPL3115A2S:
def __init__( self, i2c, addr = 0xC0 >> 1 ):
self.i2c = i2c
self.addr = addr
self.data_ready = True
@teddokano
teddokano / MPL115A1S.py
Last active June 4, 2023 20:38
MPL115A1 (a miniature SPI digital barometer, 50 to 115 kPa) operation sample for MicroPython
from machine import SPI, Pin
from utime import sleep, localtime
from struct import unpack
import os
class MPL115A1:
def __init__( self, spi, cs ):
self.spi = spi
self.cs = cs
self._get_coeff()
from machine import Pin, I2C, Timer
from utime import sleep
import machine
ADR = 0x7A >>1
class PTN5150A:
def __init__( self, i2c, address = ADR ):
self.__i2c = i2c
self.__addr = ADR
@teddokano
teddokano / ptn5150a_test.py
Created January 17, 2023 20:43
PTN5150A forcing the port as UFP when it become DFP
from machine import Pin, I2C, Timer
from utime import sleep
import machine
ADR = 0x7A >>1
class PTN5150A:
def __init__( self, i2c, address = ADR ):
self.__i2c = i2c
self.__addr = ADR
@teddokano
teddokano / pca995x_gradation_control_interface_prototype.html
Last active November 5, 2022 00:42
for "mikan" project: pca995x gradation control interface prototype
<!--
https://qiita.com/Haruka-Ogawa/items/59facd24f2a8bdb6d369
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>ui prototype</title>