Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nanoFramework.M5Core/M5Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ static M5Core()
// Setup first the I2C bus
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
// Same for PortA than for the internal one
_portANumber = 1;

// Create the energy management device
I2cDevice i2c = new(new I2cConnectionSettings(1, Ip5306.SecondaryI2cAddress));
Expand Down
8 changes: 7 additions & 1 deletion nanoFramework.M5Core2/M5Core2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static void TouchCallback(object sender, PinValueChangedEventArgs pinVal
{
_startThread = new();
_cancelThread.Cancel();
var point = _touchController.GetPoint(true);
var point = _touchController.GetPoint(true);
if ((_lastPoint.X != point.X) && (_lastPoint.Y != point.Y))
{
_lastPoint = point;
Expand Down Expand Up @@ -287,6 +287,12 @@ static M5Core2()
Configuration.SetPinFunction(13, DeviceFunction.COM2_RX);
Configuration.SetPinFunction(14, DeviceFunction.COM2_TX);

// Setup second I2C bus (port A)
Configuration.SetPinFunction(33, DeviceFunction.I2C2_CLOCK);
Configuration.SetPinFunction(32, DeviceFunction.I2C2_DATA);
// The portA is the second I2C
_portANumber = 2;

// Setup the time if any
_rtc = new Pcf8563(I2cDevice.Create(new I2cConnectionSettings(1, Pcf8563.DefaultI2cAddress)));

Expand Down
5 changes: 3 additions & 2 deletions nanoFramework.M5StackCore/M5CoreBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static partial class M5Core
private static Screen _screen;
private static SerialPort _serialPort;
private static AdcController _adc;
private static int _portANumber;

/// <summary>
/// Gets the Magnetometer.
Expand Down Expand Up @@ -113,14 +114,14 @@ public static DacChannel Dac2
/// </summary>
/// <param name="i2cDeviceAddress">The I2C device address on the bus.</param>
/// <returns>The I2cDevice.</returns>
public static I2cDevice GetI2cDevice(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress));
public static I2cDevice GetI2cDevice(int i2cDeviceAddress) => new(new I2cConnectionSettings(_portANumber, i2cDeviceAddress));

/// <summary>
/// Gets an I2C device.
/// </summary>
/// <param name="i2cDeviceAddress">The I2C device address on the bus.</param>
/// <returns>The I2cDevice.</returns>
public static I2cDevice GetGrove(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress));
public static I2cDevice GetGrove(int i2cDeviceAddress) => new(new I2cConnectionSettings(_portANumber, i2cDeviceAddress));

/// <summary>
/// Gets an SPI Device.
Expand Down