Skip to content

Instantly share code, notes, and snippets.

@mokjpn
mokjpn / M5Tank.ino
Last active Oct 3, 2021
Control Lego racer 42065 by M5StickC IR LED
View M5Tank.ino
#include <M5StickC.h>
#include <PowerFunctions.h>
PowerFunctions pf(9, 0);
#define RED_BUTTON 32
#define BLUE_BUTTON 33
#define ButtonA 37
void setup() {
@mokjpn
mokjpn / M5Zcon_HBridge.ino
Last active Oct 3, 2021
Z-gaude rail model driver by M5Atom + HBridge
View M5Zcon_HBridge.ino
#include "M5Atom.h"
#include "FastLED.h"
#include "pixeltypes.h"
// Fader Unit connected to Grove port of M5Atom Lite
#define NUM_LEDS_FADER 14
#define DATA_PIN_FADER 26
#define INPUT_PINS 32
// Define the array of leds
CRGB leds[NUM_LEDS_FADER];
@mokjpn
mokjpn / M5Zcon.ino
Last active Oct 3, 2021
M5Atom Lite + PWM Kit + Fader Unit Z-gauge train model driver
View M5Zcon.ino
#include "M5Atom.h"
#include "FastLED.h"
#include "pixeltypes.h"
// Fader Unit connected to Grove port of M5Atom Lite
#define NUM_LEDS_FADER 14
#define DATA_PIN_FADER 26
#define INPUT_PINS 32
// Define the array of leds
CRGB leds[NUM_LEDS_FADER];
@mokjpn
mokjpn / config.txt
Created Jul 15, 2021
Ubuntu 21 on Raspberry Pi + 4K ウルトラワイドモニター + ツイ廃液晶
View config.txt
[pi4]
disable_fw_kms_setup=1
max_framebuffers=2
disable_overscan=1
dtoverlay=vc4-fkms-v3d
hdmi_force_hotplug=1
boot_delay
kernel=vmlinuz
initramfs initrd.img followkernel
gpu_mem=512
@mokjpn
mokjpn / M5Atom_SinricMotionSensor.ino
Created May 13, 2020
M5Atom Sinric Motion Sensor
View M5Atom_SinricMotionSensor.ino
#include <M5Atom.h>
#include <WiFi.h>
#include <SinricPro.h>
#include <SinricProMotionsensor.h>
#define WIFI_SSID "YOUR_SSID"
#define WIFI_PASS "YOUR_WIFIPASS"
#define APP_KEY "YOUR_APPKEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "YOUR_APP_SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define MOTIONSENSOR_ID "YOUR_DEVICEID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
@mokjpn
mokjpn / PCDisplay.ino
Created May 8, 2020
Display electronic power consumption meter value via ESPNow
View PCDisplay.ino
// Display electronic power consumption meter value recieved by
// M5StickC Wi-SUN Hat ( https://kitto-yakudatsu.com/archives/7206 )
// via ESPNow
#include <TM1630LED.h>
#include <esp_now.h>
#include <WiFi.h>
#define CHANNEL 6 // Use Same Wi-Fi channel as M5StickC+Wi-SUN Hat uses.
@mokjpn
mokjpn / AtomBotter.ino
Last active May 4, 2020
M5Atom and PIR unit and Switchbot
View AtomBotter.ino
# Control SwitchBot with M5Atom+PIR sensor unit
# Many thanks to https://tech.fusic.co.jp/posts/2020-04-01-switchbot-with-m5stack/
#include <M5Atom.h>
#include "BLEDevice.h"
#define SWITCHBOT_MAC "XX:XX:XX:XX:XX:XX"
static BLEUUID serviceUUID("CBA20D00-224D-11E6-9FB8-0002A5D5C51B");
static BLEUUID characteristicUUID("CBA20002-224D-11E6-9FB8-0002A5D5C51B");
@mokjpn
mokjpn / M5StickCObnizTest.js
Created Oct 22, 2019
LCD test for M5StickC with ObnizOS
View M5StickCObnizTest.js
const m5 = require('m5stickcjs');
var obniz = new m5("XXXXXXXX");
obniz.onconnect = async function () {
// lcd = obniz.wired('ST7735S', { mosi: 15, sclk: 13, dc: 23, res:18, cs:5});
lcd = obniz.m5display;
await lcd.onWait();
console.log(lcd.width); //128
console.log(lcd.height); //160
lcd.setRotation(1);
@mokjpn
mokjpn / NogizakaDemo.Rmd
Created Nov 15, 2018
Rでe-Statの統計表から都道府県別SMRを描く
View NogizakaDemo.Rmd
---
title: "Rでe-Statの統計表から都道府県別SMRを描く"
output: html_document
---
このテキストでは、政府統計e-StatのAPIを使って、Rに直接統計表を読み込み、それを処理して特定の疾患(ICD-10に基づいた死因簡単分類で指定)の都道府県別の標準化死亡比(Standard Mortality Ratio, SMR)を算出し、その値によって都道府県を塗り分けた地図をかいてみます。すべてRの中だけで完結し、またプログラムの長さも短くて済んでいることに注目してください。
```{r, echo=FALSE, results='hide'}
appId <- "0000000000000000000000000000000000000000"
@mokjpn
mokjpn / ImaDokoStack.py
Last active Apr 12, 2018
Display ownTracks location on the M5Stack LCD.
View ImaDokoStack.py
from m5stack import lcd
from mqtt import MQTTClient
import time
import ujson
import ussl
import socket
import machine
MACHINE=hex(int.from_bytes(machine.unique_id(), 'big'))[2:]