Skip to content

Instantly share code, notes, and snippets.

@mokjpn
mokjpn / CM4Stack-TimeRecorder
Created April 12, 2023 23:39
M5StackのCM4Stackを用いてタイムレコーダーっぽいものを作る
# M5StackのCM4Stackを使って出退勤記録ボタンのようなものを作る
# このスクリプトはボタンだけで、別途用意したSubmitSyukkin.py, SubmitTaikin.py
# を起動する。CM4StackではSeleniumなども動くので幅広く応用できるかも。
import sys
import os
import time
import subprocess
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtCore import Qt, QTimer
@mokjpn
mokjpn / M5Tank.ino
Last active October 3, 2021 09:35
Control Lego racer 42065 by M5StickC IR LED
#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 October 3, 2021 09:34
Z-gaude rail model driver by M5Atom + HBridge
#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 October 3, 2021 09:35
M5Atom Lite + PWM Kit + Fader Unit Z-gauge train model driver
#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 July 15, 2021 15:56
Ubuntu 21 on Raspberry Pi + 4K ウルトラワイドモニター + ツイ廃液晶
[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 16:35
M5Atom Sinric Motion Sensor
#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 08:47
Display electronic power consumption meter value via ESPNow
// 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 15:20
M5Atom and PIR unit and Switchbot
# 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 October 22, 2019 12:50
LCD test for M5StickC with ObnizOS
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 November 15, 2018 14:49
Rでe-Statの統計表から都道府県別SMRを描く
---
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"