From 16d2b718202a2dca164b4e6fc4048e664ab20ed6 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 6 Feb 2021 11:21:37 +0100 Subject: [PATCH] all: do not use machine.TWI_FREQ_* constants These constants were always a bit weird: * they use an uncommon name (TWI instead of I2C) * they don't follow Go naming conventions (CamelCase) * the constants don't provide much value: their name is their value (100KHZ => 100e3). Therefore, I propose we remove them and replace them with regular numeric constants. --- examples/adt7410/main.go | 2 +- examples/hd44780i2c/main.go | 2 +- examples/mcp23017-multiple/main.go | 2 +- examples/mcp23017/main.go | 2 +- examples/ssd1306/i2c_128x32/main.go | 2 +- examples/tmp102/main.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/adt7410/main.go b/examples/adt7410/main.go index b633faf..a3ce756 100644 --- a/examples/adt7410/main.go +++ b/examples/adt7410/main.go @@ -15,7 +15,7 @@ var ( func main() { - i2c.Configure(machine.I2CConfig{Frequency: machine.TWI_FREQ_400KHZ}) + i2c.Configure(machine.I2CConfig{Frequency: 400e3}) sensor.Configure() for { diff --git a/examples/hd44780i2c/main.go b/examples/hd44780i2c/main.go index 1675275..df1c385 100644 --- a/examples/hd44780i2c/main.go +++ b/examples/hd44780i2c/main.go @@ -14,7 +14,7 @@ func main() { // use 3.3V (and may be damaged by 5V). machine.I2C0.Configure(machine.I2CConfig{ - Frequency: machine.TWI_FREQ_400KHZ, + Frequency: 400e3, }) lcd := hd44780i2c.New(machine.I2C0, 0x27) // some modules have address 0x3F diff --git a/examples/mcp23017-multiple/main.go b/examples/mcp23017-multiple/main.go index 14884c8..97a7b9b 100644 --- a/examples/mcp23017-multiple/main.go +++ b/examples/mcp23017-multiple/main.go @@ -10,7 +10,7 @@ import ( func main() { err := machine.I2C0.Configure(machine.I2CConfig{ - Frequency: machine.TWI_FREQ_400KHZ, + Frequency: 400e3, }) if err != nil { panic(err) diff --git a/examples/mcp23017/main.go b/examples/mcp23017/main.go index 93354be..6039f95 100644 --- a/examples/mcp23017/main.go +++ b/examples/mcp23017/main.go @@ -8,7 +8,7 @@ import ( func main() { err := machine.I2C0.Configure(machine.I2CConfig{ - Frequency: machine.TWI_FREQ_400KHZ, + Frequency: 400e3, }) if err != nil { panic(err) diff --git a/examples/ssd1306/i2c_128x32/main.go b/examples/ssd1306/i2c_128x32/main.go index 8baf37d..686689d 100644 --- a/examples/ssd1306/i2c_128x32/main.go +++ b/examples/ssd1306/i2c_128x32/main.go @@ -11,7 +11,7 @@ import ( func main() { machine.I2C0.Configure(machine.I2CConfig{ - Frequency: machine.TWI_FREQ_400KHZ, + Frequency: 400e3, }) display := ssd1306.NewI2C(machine.I2C0) diff --git a/examples/tmp102/main.go b/examples/tmp102/main.go index 5d764b4..5a732c0 100644 --- a/examples/tmp102/main.go +++ b/examples/tmp102/main.go @@ -10,7 +10,7 @@ import ( func main() { machine.I2C0.Configure(machine.I2CConfig{ - Frequency: machine.TWI_FREQ_400KHZ, + Frequency: 400e3, }) thermo := tmp102.New(machine.I2C0)