Message Boards Message Boards

GROUPS:

TOUCH PHAT evaluation on RaspberryPi Zero

Posted 1 year ago
1019 Views
|
0 Replies
|
1 Total Likes
|

PIMORONI TOUCH PHAT was tested with RaspberryPi Zero Mathematica. Without Mathematica I2C functions but using standard process i2cget and i2cput, we can control i2c peripherals connected with RaspberryPi Zero.

enter image description here

Unfortunately, TOUCH PHAT configuration of LED address and CTouch address is reversed order each other, Mathematica program must convert the address that obtained CTouch address to the LED address.

chipAdr = "0x2c";
rGet[reg_] := 
  StringTrim[
   RunProcess[{"i2cget", "-y", "1", chipAdr, reg}, "StandardOutput"]];
rPut[reg_, value_] := 
  StringTrim[
   RunProcess[{"i2cset", "-y", "1", chipAdr, reg, value}, "StandardOutput"]];

map = <| "0x01" -> "0x20", "0x02" -> "0x10", "0x04" -> "0x08", 
   "0x08" -> "0x04", "0x10" -> "0x02", "0x20" -> "0x01" |>;

While[True,
 rPut["0x00", "0x00"];
 While[(rcode = rGet["0x03"]) == "0x00"];
 rPut["0x74", map[rcode]];
 rPut["0x74", "0x00"];
 ]

$Aborted

The looped process may be aborted with Command+dot.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract