mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
machine: redesign I2C interface
This commit is contained in:
@@ -11,11 +11,10 @@ func main() {
|
||||
machine.I2C0.Configure(machine.I2CConfig{})
|
||||
|
||||
// Init BlinkM
|
||||
machine.I2C0.WriteTo(0x09, []byte("o"))
|
||||
machine.I2C0.WriteRegister(0x09, 'o', nil)
|
||||
|
||||
version := []byte{0, 0}
|
||||
machine.I2C0.WriteTo(0x09, []byte("Z"))
|
||||
machine.I2C0.ReadFrom(0x09, version)
|
||||
machine.I2C0.ReadRegister(0x09, 'Z', version)
|
||||
println("Firmware version:", string(version[0]), string(version[1]))
|
||||
|
||||
count := 0
|
||||
@@ -23,15 +22,15 @@ func main() {
|
||||
switch count {
|
||||
case 0:
|
||||
// Crimson
|
||||
machine.I2C0.WriteTo(0x09, []byte{'n', 0xdc, 0x14, 0x3c})
|
||||
machine.I2C0.WriteRegister(0x09, 'n', []byte{0xdc, 0x14, 0x3c})
|
||||
count = 1
|
||||
case 1:
|
||||
// MediumPurple
|
||||
machine.I2C0.WriteTo(0x09, []byte{'n', 0x93, 0x70, 0xdb})
|
||||
machine.I2C0.WriteRegister(0x09, 'n', []byte{0x93, 0x70, 0xdb})
|
||||
count = 2
|
||||
case 2:
|
||||
// MediumSeaGreen
|
||||
machine.I2C0.WriteTo(0x09, []byte{'n', 0x3c, 0xb3, 0x71})
|
||||
machine.I2C0.WriteRegister(0x09, 'n', []byte{0x3c, 0xb3, 0x71})
|
||||
count = 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user