Skip to content

Instantly share code, notes, and snippets.

View katsuyoshi's full-sized avatar

Katsuyoshi Ito katsuyoshi

  • ITO SOFT DESIGN Inc.
  • Akita, Japan
View GitHub Profile
import UIKit
import PlaygroundSupport
import Combine
class MyViewController : UIViewController {
var label: UILabel!
var sub: AnyCancellable!
override func loadView() {
@katsuyoshi
katsuyoshi / ContentView.swift
Last active March 17, 2023 07:29
iOSのBackgrounTaskでデッドロック
import SwiftUI
struct ContentView: View {
@Environment(\.scenePhase) var scenePhase
@State var controller = Controller()
@ObservedObject var publisher = Publisher()
var body: some View {
VStack {
Image(systemName: "globe")
@katsuyoshi
katsuyoshi / main.cpp
Last active June 7, 2024 13:15
M5AtomS3とToioで倒立振子に挑戦
#include <Arduino.h>
#include <M5Unified.h>
#include <MadgwickAHRS.h>
#define Serial USBSerial
Madgwick madgwick = Madgwick();
float roll = 0;
float pitch = 0;
@katsuyoshi
katsuyoshi / main.cpp
Last active March 7, 2023 15:12
M5AtomS3でソニーテレビの赤外線リモコン信号を送信
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <M5Unified.h>
#ifndef USE_USEBSERIAL
#define USBSerial Serial
#endif
static uint16_t kIrLed = 4;
@katsuyoshi
katsuyoshi / main.cpp
Last active March 5, 2023 13:56
M5AtomS3でIR受信データを確認。IRremoteESP8266のサンプルIRrecvDumpV2を変更していく
/*
* IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input kRecvPin.
*
* Copyright 2009 Ken Shirriff, http://arcfn.com
* Copyright 2017-2019 David Conran
*
* Example circuit diagram:
* https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-receiving
*
@katsuyoshi
katsuyoshi / ContentView.swift
Created February 24, 2023 07:11
CoreDataのwillSave()を使う際はsetPrimitiveValue(:forkey:)を使う
import SwiftUI
import CoreData
struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
animation: .default)
private var items: FetchedResults<Item>
#include <Arduino.h>
#include <FastLED.h>
#define LED_PIN 21
#define NUM_LEDS 1
static CRGB leds[NUM_LEDS];
void setLed(CRGB color) {
// change RGB to GRB
@katsuyoshi
katsuyoshi / ContetView.swift
Last active February 12, 2023 13:39
TextFieldでoptionalを扱う場合について
import SwiftUI
struct ModelView: View {
@ObservedObject var model: Model
@State var isEditing = false
var body: some View {
HStack {
Text(model.name)
@katsuyoshi
katsuyoshi / ContentView.swift
Last active February 10, 2023 07:57
SwiftUIでUndoManagerを試してみる
import SwiftUI
struct ContentView: View {
@ObservedObject var model = Model()
var body: some View {
VStack {
Toggle("On/Off", isOn: $model.isOn)
Spacer()
Button("Undo") {
@katsuyoshi
katsuyoshi / result
Created January 16, 2023 23:55
objcで [[self class] new] とするのを Swift で
Hello, I'm an instance of A.
Hello, I'm an instance of A.
Hello, I'm an instance of B.
Hello, I'm an instance of B.