Message Boards Message Boards

TOUCH PHAT evaluation on RaspberryPi Zero


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_] := 
   RunProcess[{"i2cget", "-y", "1", chipAdr, reg}, "StandardOutput"]];
rPut[reg_, value_] := 
   RunProcess[{"i2cset", "-y", "1", chipAdr, reg, value}, "StandardOutput"]];

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

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


The looped process may be aborted with Command+dot.

POSTED BY: Hirokazu Kobayashi
1 month ago

Group Abstract Group Abstract