Skip to content

Instantly share code, notes, and snippets.

View hasumikin's full-sized avatar
🐕‍🦺
inu

HASUMI Hitoshi hasumikin

🐕‍🦺
inu
View GitHub Profile
@hasumikin
hasumikin / .irbrc
Created November 8, 2023 00:25
Configuring IRBRC to improve the visibility of completion dialog colors
# Make sure you installed reline 0.4.0+
Reline::Face.config(:completion_dialog) do |conf|
conf.define :default, foreground: :white, background: :blue
# ^^^^^ :cyan by default
conf.define :enhanced, foreground: :white, background: :magenta
conf.define :scrollbar, foreground: :white, background: :blue
end
@hasumikin
hasumikin / memo.md
Created June 7, 2023 14:35
mruby、mruby/c(PicoRuby)のペリフェラルAPI共通規格のドキュメントを整備したい

やりたいこと

  • mruby、mruby/c(PicoRuby)のペリフェラルAPI共通規格のドキュメントを整備したい

ペリフェラルとは

  • マイコンの入出力に関する各種の規格
  • 今回の対象になりそうなのは、GPIO, ADC, I2C, API, UART, PWM

mruby、mruby/cの「共通規格」とは

  • 軽量Rubyフォーラム(mrubyのメンテ主体)、九州工業大およびITOC(mruby/cのメンテ主体)の共同の取り組み
  • マイコンでのRuby利用を促進するため、標準的なAPI規格を策定する(している)。そして公開したい(←これが重要)
@hasumikin
hasumikin / keymap.rb
Created April 19, 2023 23:46
PRK Firmware ADC example
require "adc"
require "mouse"
kbd = Keyboard.new
kbd.init_direct_pins( [8] )
kbd.add_layer :default, %i(BOOTSEL)
kbd.define_mode_key :BOOTSEL, [ Proc.new { kbd.bootsel! }, nil, 300, nil ]
@hasumikin
hasumikin / keymap.rb
Created April 19, 2023 23:45
PRK Firmware SPI example (Keyball44)
require "spi"
require "mouse"
require "consumer_key"
class SPI
def pmw3360dm_write(*values)
GPIO.write_at(21, 0)
write(*values)
Machine.delay_us 20
GPIO.write_at(21, 1)
@hasumikin
hasumikin / keymap.rb
Created April 19, 2023 23:45
PRK Firmware I2C example
#
# Pin assignment:
# switch matrix:
# row: 1, 2, 3, 4
# col: 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
# RGBLED: 0
# I2C0: trackball and RTC
# sda_pin: 20
# scl_pin: 21
# SPI1:
@hasumikin
hasumikin / gist:c14a75aedc05de046cb39778145338b1
Created November 29, 2022 07:06
例のMaximum call stack size exceededのエラーメッセージ
$ #
$ # irb.wasm - IRB on CRuby on WebAssembly
$ #
$ # Source code is available at https://github.com/kateinoigakukun/irb.wasm
$ #
$ # QUICK START
$ # 1. Install gem by `gem "haml"
$ # 2. `require "haml"`
$ # 3. `Term.echo Haml::Template.new { "%h1 Haml code!" }.render`
$ #
@hasumikin
hasumikin / Picoprobe.md
Last active November 9, 2022 05:45
Debug a Pi Pico app with Picoprobe(WSL2)

Run Powershell as an admin

  • usbipd list to find the Picoprobe's BUSID
  • If the BUSID is 2-2,
  • usbipd wsl attach --busid 2-2

On a terminal

  • openocd

On another terminal

  • gdb-pico [project].elf
@hasumikin
hasumikin / keymap.rb
Last active June 12, 2022 02:51
Sample PRK Firmware keymap for Bolt Industries Pico 87
puts "==== Pico87 ===="
kbd = Keyboard.new
kbd.init_pins(
[ 18, 19, 20, 21, 22, 26 ],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
)
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
@hasumikin
hasumikin / keymap.rb
Created May 6, 2022 02:51
Simulating "Grave Escape" feature of QMK
class Keyboard
def grave_escape
index = @keycodes.index(KEYCODE.index(:KC_ESCAPE).chr)
if index
if (@modifier & 0b00010001) > 0 # CTRL
# Do nothing so that "SHIFT+CTRL+ESCAPE" opens Task Manager
elsif (@modifier & 0b00100010) > 0 # SHIFT
@keycodes[index] = KEYCODE.index(:KC_GRAVE).chr
elsif (@modifier & 0b10001000) > 0 # GUI
@keycodes[index] = KEYCODE.index(:KC_GRAVE).chr
@hasumikin
hasumikin / keymap.rb
Created February 6, 2022 23:35
Shotgun CherryPie example keymap
kbd = Keyboard.new
kbd.init_pins(
[ 11, 12, 13, 14, 15 ], # row0, row1,... respectively
[ 9, 8, 7, 6 ] # col0, col1,... respectively
)
kbd.add_layer :default, %i[
RGB_TOG KC_ESC KC_NO KC_BSPACE
RGB_MOD KC_7 KC_8 KC_9