45#include <scolMemoryHelper.hpp>
49#include "rpishiftdriver.h"
52#include "rpiPCA9685.h"
73int OBJ_GPIOSERVO_SCOL;
74int GPIOSERVO_NB_CB = 0;
75int OBJ_GPIOSHIFTDRIVER_SCOL;
76int GPIOSHIFTDRIVER_NB_CB = 0;
79int OBJ_GPIOPCA9685_SCOL;
80int GPIOPCA9685_NB_CB = 0;
82int GPIOECHO_NB_CB = 0;
94 int iDelay = MMget(m, 0);
99 iDelay = MTOI(iDelay);
105 MMset(m, 0, ITOM(1));
119 int iDelay = MMget(m, 0);
124 iDelay = MTOI(iDelay);
127 delayMicroseconds(iDelay);
130 MMset(m, 0, ITOM(1));
146 int iMode = MMpull(m);
147 int iPin = MMpull(m);
148 int chn = MMget(m, 0);
152 MMechostr(MSKDEBUG,
"_crGPIOpin error : channel is nil...\n");
156 if (iPin == NIL || iMode == NIL)
158 MMechostr(MSKDEBUG,
"_crGPIOpin error : pin or mode is nil...\n");
166 if (iMode == GPIO_CLOCK && iPin != 4)
168 MMechostr(MSKDEBUG,
"_setGPIOpinMode error : GPIO_CLOCK is only available for pin 4...\n");
176 if ((MMpushPointer(m, pinobj) != 0))
183 return OBJcreate(m, OBJ_GPIOPIN_SCOL, SCOL_PTR pinobj, NIL, 0);
197 MMechostr(MSKDEBUG,
"_dsGPIOpin\n");
200 int objtab = MMget(m, 0);
203 MMechostr(MSKDEBUG,
"_dsGPIOpin : ObjGpioPin is NIL\n");
208 OBJdelTM(m, OBJ_GPIOPIN_SCOL, objtab);
209 MMset(m, 0, ITOM(0));
212 MMechostr(MSKDEBUG,
"ok\n");
228 int iMode = MMpull(m);
229 int iPinObj = MMget(m, 0);
231 if (iPinObj == NIL || iMode == NIL)
233 MMechostr (MSKDEBUG,
"_setGPIOpinPullMode error : pin object or mode is nil...\n");
240 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
247 gpioPinObj->SetPullUpDnControl(iMode);
249 MMset(m, 0, ITOM(1));
264 int iVal = MMpull(m);
265 int iPinObj = MMget(m, 0);
267 if (iPinObj == NIL || iVal == NIL)
269 MMechostr (MSKDEBUG,
"_GPIOdigitalWrite error : pin object or value is nil...\n");
281 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
288 gpioPinObj->DigitalWrite(iVal);
290 MMset(m, 0, ITOM(1));
304 int iPinObj = MMget(m, 0);
308 MMechostr (MSKDEBUG,
"_GPIOdigitalRead error : pin object is nil...\n");
313 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
320 MMset(m, 0, ITOM(gpioPinObj->DigitalRead()));
335 int iVal = MMpull(m);
336 int iPinObj = MMget(m, 0);
338 if (iPinObj == NIL || iVal == NIL)
340 MMechostr (MSKDEBUG,
"_GPIOanalogWrite error : pin object or value is nil...\n");
347 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
354 gpioPinObj->AnalogWrite(iVal);
356 MMset(m, 0, ITOM(1));
370 int iPinObj = MMget(m, 0);
374 MMechostr (MSKDEBUG,
"_GPIOanalogRead error : pin object is nil...\n");
379 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
386 MMset(m, 0, ITOM(gpioPinObj->AnalogRead()));
401 int iVal = MMpull(m);
402 int iPinObj = MMget(m, 0);
404 if (iPinObj == NIL || iVal == NIL)
406 MMechostr(MSKDEBUG,
"_GPIOpwmWrite error : pin object or value is nil...\n");
413 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(iPinObj));
420 gpioPinObj->PwmWrite(iVal);
422 MMset(m, 0, ITOM(1));
457 int iStrb = MMpull(m);
459 int iBits = MMpull(m);
460 int iCols = MMpull(m);
461 int iRows = MMpull(m);
462 int chn = MMget(m, 0);
466 MMechostr(MSKDEBUG,
"_crGPIOlcd error : channel is nil...\n");
470 if (iRows == NIL || iCols == NIL || iBits == NIL || iRs == NIL || iStrb == NIL || iD0 == NIL || iD1 == NIL || iD2 == NIL || iD4 == NIL)
472 MMechostr(MSKDEBUG,
"_crGPIOlcd error : missing parameter...\n");
489 RpiLCD* lcdobj =
new RpiLCD(MTOI(iRows), MTOI(iCols), MTOI(iBits), MTOI(iRs), MTOI(iStrb), MTOI(iD0), MTOI(iD1), MTOI(iD2), MTOI(iD3), MTOI(iD4), MTOI(iD5), MTOI(iD6), MTOI(iD7));
492 if ((MMpushPointer(m, lcdobj) != 0))
499 return OBJcreate(m, OBJ_GPIOLCD_SCOL, SCOL_PTR lcdobj, NIL, 0);
513 MMechostr(MSKDEBUG,
"_dsGPIOlcd\n");
516 int objtab = MMget(m, 0);
519 MMechostr(MSKDEBUG,
"_dsGPIOpin : ObjGpioLcd is NIL\n");
524 OBJdelTM(m, OBJ_GPIOLCD_SCOL, objtab);
525 MMset(m, 0, ITOM(0));
528 MMechostr(MSKDEBUG,
"ok\n");
543 int iLcdObj = MMget(m, 0);
547 MMechostr(MSKDEBUG,
"_GPIOlcdHome error : Lcd handle is nil...\n");
552 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
561 MMset(m, 0, ITOM(1));
575 int iLcdObj = MMget(m, 0);
579 MMechostr(MSKDEBUG,
"_GPIOlcdClear error : Lcd handle is nil...\n");
584 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
593 MMset(m, 0, ITOM(1));
608 int iState = MMpull(m);
609 int iLcdObj = MMget(m, 0);
613 MMechostr(MSKDEBUG,
"_GPIOlcdDisplay error : Lcd handle is nil...\n");
618 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
625 if (iState == NIL || MTOI(iState) <= 0)
630 gpioLcdObj->DisplayState(iState);
632 MMset(m, 0, ITOM(1));
647 int iState = MMpull(m);
648 int iLcdObj = MMget(m, 0);
652 MMechostr(MSKDEBUG,
"_GPIOlcdDisplay error : Lcd handle is nil...\n");
657 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
664 if (iState == NIL || MTOI(iState) <= 0)
669 gpioLcdObj->CursorState(iState);
671 MMset(m, 0, ITOM(1));
686 int iState = MMpull(m);
687 int iLcdObj = MMget(m, 0);
691 MMechostr(MSKDEBUG,
"_GPIOlcdDisplay error : Lcd handle is nil...\n");
696 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
703 if (iState == NIL || MTOI(iState) <= 0)
708 gpioLcdObj->CursorBlink(iState);
710 MMset(m, 0, ITOM(1));
728 int iLcdObj = MMget(m, 0);
732 MMechostr(MSKDEBUG,
"_GPIOlcdDisplay error : Lcd handle is nil...\n");
737 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
744 if (iX == NIL || MTOI(iX) <= 0)
749 if (iY == NIL || MTOI(iY) <= 0)
754 gpioLcdObj->SetPosition(iX, iY);
756 MMset(m, 0, ITOM(1));
771 int iText = MMpull(m);
772 int iLcdObj = MMget(m, 0);
776 MMechostr(MSKDEBUG,
"_GPIOlcdDisplay error : Lcd handle is nil...\n");
781 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(iLcdObj));
788 std::string txtout =
"";
790 txtout = MMstartstr(m, MTOP(iText));
794 MMechostr(MSKDEBUG,
"_GPIOlcdPuts error : no text to print...\n");
799 gpioLcdObj->Puts(txtout);
801 MMset(m, 0, ITOM(1));
818 int iValue = MMpull(m);
819 int iPin = MMpull(m);
820 int chn = MMget(m, 0);
824 MMechostr(MSKDEBUG,
"_crGPIOservo error : channel is nil...\n");
830 MMechostr(MSKDEBUG,
"_crGPIOservo error : pin is nil...\n");
839 value = MTOF(iValue);
844 if ((MMpushPointer(m, servoObj) != 0))
846 SAFE_DELETE(servoObj);
851 return OBJcreate(m, OBJ_GPIOSERVO_SCOL, SCOL_PTR servoObj, NIL, 0);
865 MMechostr(MSKDEBUG,
"_dsGPIOservo\n");
868 int objtab = MMget(m, 0);
871 MMechostr(MSKDEBUG,
"_dsGPIOservo : ObjGpioServo is NIL\n");
876 OBJdelTM(m, OBJ_GPIOSERVO_SCOL, objtab);
877 MMset(m, 0, ITOM(0));
880 MMechostr(MSKDEBUG,
"ok\n");
897 int iValue = MMpull(m);
898 int iServoObj = MMget(m, 0);
900 if (iServoObj == NIL)
902 MMechostr(MSKDEBUG,
"_setGPIOservoAngle error : servo object is nil...\n");
909 value = MTOF(iValue);
911 RpiServo* servoObj = MMgetPointer<RpiServo*>(m, MTOP(iServoObj));
918 servoObj->WriteValue(value);
920 MMset(m, 0, ITOM(1));
939 int iNbOut = MMpull(m);
940 int iLatch = MMpull(m);
941 int iClock = MMpull(m);
942 int iData = MMpull(m);
943 int chn = MMget(m, 0);
947 MMechostr(MSKDEBUG,
"_crGPIOshiftDriver error : channel is nil...\n");
951 if ((iData == NIL) || (iClock == NIL) || (iLatch == NIL))
953 MMechostr(MSKDEBUG,
"_crGPIOshiftDriver error : pin is nil...\n");
959 iClock = MTOI(iClock);
960 iLatch = MTOI(iLatch);
961 iNbOut = (iNbOut == NIL) ? 8 : MTOI(iNbOut);
966 if ((MMpushPointer(m, shiftDriverObj) != 0))
968 SAFE_DELETE(shiftDriverObj);
973 return OBJcreate(m, OBJ_GPIOSHIFTDRIVER_SCOL, SCOL_PTR shiftDriverObj, NIL, 0);
987 MMechostr(MSKDEBUG,
"_dsGPIOservo\n");
990 int objtab = MMget(m, 0);
993 MMechostr(MSKDEBUG,
"_dsGPIOshiftDriver : ObjGpioShiftDriver is NIL\n");
998 OBJdelTM(m, OBJ_GPIOSHIFTDRIVER_SCOL, objtab);
999 MMset(m, 0, ITOM(0));
1002 MMechostr(MSKDEBUG,
"ok\n");
1019 int iValues = MMpull(m);
1020 int iShiftRegisterObj = MMget(m, 0);
1022 if (iShiftRegisterObj == NIL)
1024 MMechostr(MSKDEBUG,
"_setGPIOshiftDriverValues error : ObjGpioShiftDriver is nil...\n");
1029 RpiShiftDriver* gpioShiftDriverObj = MMgetPointer<RpiShiftDriver*>(m, MTOP(iShiftRegisterObj));
1030 if (gpioShiftDriverObj == 0)
1036 std::vector<RpiShiftDriver::shiftValue> values;
1043 iValues = MTOP(iValues);
1044 while (iValues != NIL)
1047 dataTuple = MTOP(MMfetch(m, iValues, 0));
1048 val = MTOI(MMfetch(m, dataTuple, 0));
1049 tm = MTOI(MMfetch(m, dataTuple, 1));
1050 iValues = MTOP(MMfetch(m, iValues, 1));
1053 values.push_back(RpiShiftDriver::shiftValue(val, tm));
1056 gpioShiftDriverObj->SetValues(values);
1058 MMset(m, 0, ITOM(1));
1073 int iDeviceId = MMpull(m);
1074 int chn = MMget(m, 0);
1078 MMechostr(MSKDEBUG,
"_crGPIOi2c error : channel is nil...\n");
1082 if (iDeviceId == NIL)
1084 MMechostr(MSKDEBUG,
"_crGPIOi2c error : Device ID is nil...\n");
1089 iDeviceId = MTOI(iDeviceId);
1094 if ((MMpushPointer(m, pinobj) != 0))
1096 SAFE_DELETE(pinobj);
1101 return OBJcreate(m, OBJ_GPIOI2C_SCOL, SCOL_PTR pinobj, NIL, 0);
1115 MMechostr(MSKDEBUG,
"_dsGPIOi2c\n");
1118 int objtab = MMget(m, 0);
1121 MMechostr(MSKDEBUG,
"_dsGPIOi2c : ObjGpioI2C is NIL\n");
1126 OBJdelTM(m, OBJ_GPIOI2C_SCOL, objtab);
1127 MMset(m, 0, ITOM(0));
1130 MMechostr(MSKDEBUG,
"ok\n");
1146 int iVal = MMpull(m);
1147 int iI2CObj = MMget(m, 0);
1149 if (iI2CObj == NIL || iVal == NIL)
1151 MMechostr (MSKDEBUG,
"_GPIOi2cWrite error : I2C object or value is nil...\n");
1158 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1159 if (gpioI2CObj == 0)
1165 gpioI2CObj->Write(iVal);
1167 MMset(m, 0, ITOM(1));
1181 int iI2CObj = MMget(m, 0);
1185 MMechostr (MSKDEBUG,
"_GPIOi2cRead error : I2C object is nil...\n");
1190 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1191 if (gpioI2CObj == 0)
1197 MMset(m, 0, ITOM(gpioI2CObj->Read()));
1213 int iVal = MMpull(m);
1214 int iReg = MMpull(m);
1215 int iI2CObj = MMget(m, 0);
1217 if (iI2CObj == NIL || iVal == NIL)
1219 MMechostr (MSKDEBUG,
"_GPIOi2cWrite8 error : I2C object or value is nil...\n");
1226 MMechostr (MSKDEBUG,
"_GPIOi2cWrite8 error : I2C register is nil...\n");
1234 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1235 if (gpioI2CObj == 0)
1241 gpioI2CObj->WriteReg8(iReg, iVal);
1243 MMset(m, 0, ITOM(1));
1258 int iReg = MMpull(m);
1259 int iI2CObj = MMget(m, 0);
1263 MMechostr (MSKDEBUG,
"_GPIOi2cRead8 error : I2C object object is nil...\n");
1270 MMechostr (MSKDEBUG,
"_GPIOi2cRead8 error : I2C register is nil...\n");
1277 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1278 if (gpioI2CObj == 0)
1284 MMset(m, 0, ITOM(gpioI2CObj->ReadReg8(iReg)));
1300 int iVal = MMpull(m);
1301 int iReg = MMpull(m);
1302 int iI2CObj = MMget(m, 0);
1304 if (iI2CObj == NIL || iVal == NIL)
1306 MMechostr (MSKDEBUG,
"_GPIOi2cWrite16 error : I2C object or value is nil...\n");
1313 MMechostr (MSKDEBUG,
"_GPIOi2cWrite16 error : I2C register is nil...\n");
1321 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1322 if (gpioI2CObj == 0)
1328 gpioI2CObj->WriteReg16(iReg, iVal);
1330 MMset(m, 0, ITOM(1));
1345 int iReg = MMpull(m);
1346 int iI2CObj = MMget(m, 0);
1350 MMechostr (MSKDEBUG,
"_GPIOi2cRead16 error : I2C object object is nil...\n");
1357 MMechostr (MSKDEBUG,
"_GPIOi2cRead16 error : I2C register is nil...\n");
1364 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(iI2CObj));
1365 if (gpioI2CObj == 0)
1371 MMset(m, 0, ITOM(gpioI2CObj->ReadReg16(iReg)));
1388 int iFrequency = MMpull(m);
1389 int iPinBase = MMpull(m);
1390 int iDeviceId = MMpull(m);
1391 int chn = MMget(m, 0);
1395 MMechostr(MSKDEBUG,
"_crGPIOpca9685 error : channel is nil...\n");
1399 if (iDeviceId == NIL)
1401 MMechostr(MSKDEBUG,
"_crGPIOpca9685 error : Device ID is nil...\n");
1406 iDeviceId = MTOI(iDeviceId);
1408 if (iPinBase == NIL)
1411 iPinBase = MTOI(iPinBase);
1413 if (iFrequency == NIL)
1416 iFrequency = MTOI(iFrequency);
1421 if ((MMpushPointer(m, pca9685Obj) != 0))
1423 SAFE_DELETE(pca9685Obj);
1428 return OBJcreate(m, OBJ_GPIOPCA9685_SCOL, SCOL_PTR pca9685Obj, NIL, 0);
1442 MMechostr(MSKDEBUG,
"_dsGPIOpca9685\n");
1445 int objtab = MMget(m, 0);
1448 MMechostr(MSKDEBUG,
"_dsGPIOpca9685 : ObjGpioPCA9685 is NIL\n");
1453 OBJdelTM(m, OBJ_GPIOPCA9685_SCOL, objtab);
1454 MMset(m, 0, ITOM(0));
1457 MMechostr(MSKDEBUG,
"ok\n");
1475 int iVal = MMpull(m);
1476 int iPin = MMpull(m);
1477 int iPCA9685 = MMget(m, 0);
1479 if (iPCA9685 == NIL || iPin == NIL || iVal == NIL)
1481 MMechostr (MSKDEBUG,
"_GPIOpca9685Write error : I2C object, pin or value is nil...\n");
1489 RpiPCA9685* gpioI2CObj = MMgetPointer<RpiPCA9685*>(m, MTOP(iPCA9685));
1490 if (gpioI2CObj == 0)
1496 gpioI2CObj->PwmWrite(iPin, iVal);
1498 MMset(m, 0, ITOM(1));
1513 int iPin = MMpull(m);
1514 int iPCA9685 = MMget(m, 0);
1516 if (iPCA9685 == NIL || iPin == NIL)
1518 MMechostr (MSKDEBUG,
"_GPIOpca9685Read error : I2C object or pin is nil...\n");
1523 RpiPCA9685* gpioI2CObj = MMgetPointer<RpiPCA9685*>(m, MTOP(iPCA9685));
1524 if (gpioI2CObj == 0)
1532 MMset(m, 0, ITOM(gpioI2CObj->PwmRead(iPin)));
1546 int iPCA9685 = MMget(m, 0);
1548 if (iPCA9685 == NIL)
1550 MMechostr (MSKDEBUG,
"_GPIOpca9685Reset error : I2C object is nil...\n");
1555 RpiPCA9685* gpioI2CObj = MMgetPointer<RpiPCA9685*>(m, MTOP(iPCA9685));
1556 if (gpioI2CObj == 0)
1562 gpioI2CObj->Reset();
1564 MMset(m, 0, ITOM(1));
1579 int iFrequency = MMpull(m);
1580 int iPCA9685 = MMget(m, 0);
1582 if (iPCA9685 == NIL)
1584 MMechostr (MSKDEBUG,
"_GPIOpca9685SetFrequency error : I2C object is nil...\n");
1589 if (iFrequency == NIL)
1592 iFrequency = MTOI(iFrequency);
1594 RpiPCA9685* gpioI2CObj = MMgetPointer<RpiPCA9685*>(m, MTOP(iPCA9685));
1595 if (gpioI2CObj == 0)
1601 gpioI2CObj->SetFrequency(iFrequency);
1603 MMset(m, 0, ITOM(1));
1622 int iEchoPin = MMpull(m);
1623 int iTriggerPin = MMpull(m);
1624 int chn = MMget(m, 0);
1628 MMechostr(MSKDEBUG,
"_crGPIOecho error : channel is nil...\n");
1632 if (iTriggerPin == NIL || iEchoPin == NIL)
1634 MMechostr(MSKDEBUG,
"_crGPIOecho error : pin is nil...\n");
1639 iTriggerPin = MTOI(iTriggerPin);
1640 iEchoPin = MTOI(iEchoPin);
1645 if ((MMpushPointer(m, echoObj) != 0))
1647 SAFE_DELETE(echoObj);
1652 return OBJcreate(m, OBJ_GPIOECHO_SCOL, SCOL_PTR echoObj, NIL, 0);
1666 MMechostr(MSKDEBUG,
"_dsGPIOecho\n");
1669 int objtab = MMget(m, 0);
1672 MMechostr(MSKDEBUG,
"_dsGPIOecho : ObjGpioEcho is NIL\n");
1677 OBJdelTM(m, OBJ_GPIOECHO_SCOL, objtab);
1678 MMset(m, 0, ITOM(0));
1681 MMechostr(MSKDEBUG,
"ok\n");
1697 int iEchoObj = MMget(m, 0);
1699 if (iEchoObj == NIL)
1701 MMechostr(MSKDEBUG,
"_getGPIOechoValue error : echo object is nil...\n");
1706 RpiEcho* echoObj = MMgetPointer<RpiEcho*>(m, MTOP(iEchoObj));
1713 MMset(m, 0, ITOM((
int)echoObj->ReadValue()));
1717NativeDefinition rpiGPIOEngine[] =
1719 {
"ObjGpioI2C", TYPTYPE, NULL, NULL },
1720 {
"ObjGpioPCA9685", TYPTYPE, NULL, NULL },
1721 {
"ObjGpioShiftDriver", TYPTYPE, NULL, NULL },
1722 {
"ObjGpioServo", TYPTYPE, NULL, NULL },
1723 {
"ObjGpioLcd", TYPTYPE, NULL, NULL },
1724 {
"ObjGpioPin", TYPTYPE, NULL, NULL },
1725 {
"GPIO_DIGITAL_INPUT", TYPVAR,
"I", SCOL_TYPTYPE(SOFT_DIGITAL_INPUT) },
1726 {
"GPIO_INPUT", TYPVAR,
"I", SCOL_TYPTYPE(INPUT) },
1727 {
"GPIO_OUTPUT", TYPVAR,
"I", SCOL_TYPTYPE(OUTPUT) },
1728 {
"GPIO_CLOCK", TYPVAR,
"I", SCOL_TYPTYPE(GPIO_CLOCK) },
1729 {
"GPIO_PWM_OUTPUT", TYPVAR,
"I", SCOL_TYPTYPE(PWM_OUTPUT) },
1730 {
"GPIO_HIGH", TYPVAR,
"I", SCOL_TYPTYPE(HIGH) },
1731 {
"GPIO_LOW", TYPVAR,
"I", SCOL_TYPTYPE(LOW) },
1732 {
"GPIO_PUD_DOWN", TYPVAR,
"I", SCOL_TYPTYPE(PUD_DOWN) },
1733 {
"GPIO_PUD_UP", TYPVAR,
"I", SCOL_TYPTYPE(PUD_UP) },
1734 {
"GPIO_PUD_OFF", TYPVAR,
"I", SCOL_TYPTYPE(PUD_OFF) },
1735 {
"_GPIOdelay", 1,
"fun [I] I",
_GPIOdelay },
1738 {
"_crGPIOpin", 3,
"fun [Chn I I] ObjGpioPin",
_crGPIOpin },
1739 {
"_dsGPIOpin", 1,
"fun [ObjGpioPin] I",
_dsGPIOpin },
1745 {
"_GPIOpwmWrite", 2,
"fun [ObjGpioPin I] I",
_GPIOpwmWrite },
1747 {
"_crGPIOlcd", 14,
"fun [Chn I I I I I I I I I I I I I] ObjGpioLcd",
_crGPIOlcd },
1748 {
"_dsGPIOlcd", 1,
"fun [ObjGpioLcd] I",
_dsGPIOlcd },
1749 {
"_GPIOlcdHome", 1,
"fun [ObjGpioLcd] I",
_GPIOlcdHome },
1750 {
"_GPIOlcdClear", 1,
"fun [ObjGpioLcd] I",
_GPIOlcdClear },
1755 {
"_GPIOlcdPuts", 2,
"fun [ObjGpioLcd S] I",
_GPIOlcdPuts },
1757 {
"_crGPIOservo", 3,
"fun [Chn I F] ObjGpioServo",
_crGPIOservo },
1758 {
"_dsGPIOservo", 1,
"fun [ObjGpioServo] I",
_dsGPIOservo },
1761 {
"_crGPIOshiftDriver", 5,
"fun [Chn I I I I] ObjGpioShiftDriver",
_crGPIOshiftDriver },
1765 {
"_crGPIOi2c", 2,
"fun [Chn I] ObjGpioI2C",
_crGPIOi2c },
1766 {
"_dsGPIOi2c", 1,
"fun [ObjGpioI2C] I",
_dsGPIOi2c },
1767 {
"_GPIOi2cWrite", 2,
"fun [ObjGpioI2C I] I",
_GPIOi2cWrite },
1768 {
"_GPIOi2cRead", 1,
"fun [ObjGpioI2C] I",
_GPIOi2cRead },
1769 {
"_GPIOi2cWrite8", 3,
"fun [ObjGpioI2C I I] I",
_GPIOi2cWrite8 },
1770 {
"_GPIOi2cRead8", 2,
"fun [ObjGpioI2C I] I",
_GPIOi2cRead8 },
1774 {
"_crGPIOpca9685", 4,
"fun [Chn I I I] ObjGpioPCA9685",
_crGPIOpca9685 },
1775 {
"_dsGPIOpca9685", 1,
"fun [ObjGpioPCA9685] I",
_dsGPIOpca9685 },
1781 {
"_crGPIOecho", 3,
"fun [Chn I I] ObjGpioEcho",
_crGPIOecho },
1782 {
"_dsGPIOecho", 1,
"fun [ObjGpioEcho] I",
_dsGPIOecho },
1788int destroyGPIOpin(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1790 RpiPin* gpioPinObj = MMgetPointer<RpiPin*>(m, MTOP(objtab));
1791 SAFE_DELETE(gpioPinObj);
1792 MMsetPointer<RpiPin*>(m, MTOP(objtab), 0);
1798int destroyGPIOlcd(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1800 RpiLCD* gpioLcdObj = MMgetPointer<RpiLCD*>(m, MTOP(objtab));
1801 SAFE_DELETE(gpioLcdObj);
1802 MMsetPointer<RpiLCD*>(m, MTOP(objtab), 0);
1808int destroyGPIOservo(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1810 RpiServo* gpioServoObj = MMgetPointer<RpiServo*>(m, MTOP(objtab));
1811 SAFE_DELETE(gpioServoObj);
1812 MMsetPointer<RpiServo*>(m, MTOP(objtab), 0);
1818int destroyGPIOshiftDriver(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1820 RpiShiftDriver* gpioShiftDriverObj = MMgetPointer<RpiShiftDriver*>(m, MTOP(objtab));
1821 SAFE_DELETE(gpioShiftDriverObj);
1822 MMsetPointer<RpiServo*>(m, MTOP(objtab), 0);
1828int destroyGPIOi2c(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1830 RpiI2C* gpioI2CObj = MMgetPointer<RpiI2C*>(m, MTOP(objtab));
1831 SAFE_DELETE(gpioI2CObj);
1832 MMsetPointer<RpiI2C*>(m, MTOP(objtab), 0);
1838int destroyGPIOpca9685(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1840 RpiPCA9685* gpioPCA9685Obj = MMgetPointer<RpiPCA9685*>(m, MTOP(objtab));
1841 SAFE_DELETE(gpioPCA9685Obj);
1842 MMsetPointer<RpiPCA9685*>(m, MTOP(objtab), 0);
1848int destroyGPIOecho(mmachine m, SCOL_PTR_TYPE handsys,
int objtab)
1850 RpiEcho* gpioEchoObj = MMgetPointer<RpiEcho*>(m, MTOP(objtab));
1851 SAFE_DELETE(gpioEchoObj);
1852 MMsetPointer<RpiEcho*>(m, MTOP(objtab), 0);
1863int LoadGPIO(mmachine m)
1870 MMechostr(MSKDEBUG,
"Init GPIO with sys mode, note that you need root privilieges for full support.\n");
1875 MMechostr(MSKDEBUG,
"Init GPIO, with root privilieges and full support.\n");
1876 wiringPiSetupGpio();
1880 OBJ_GPIOPIN_SCOL = OBJregister(GPIOPIN_NB_CB, 0, destroyGPIOpin,
"GPIOPin");
1881 OBJ_GPIOLCD_SCOL = OBJregister(GPIOLCD_NB_CB, 0, destroyGPIOlcd,
"GPIOLcd");
1882 OBJ_GPIOSERVO_SCOL = OBJregister(GPIOSERVO_NB_CB, 0, destroyGPIOservo,
"GPIOServo");
1883 OBJ_GPIOSHIFTDRIVER_SCOL = OBJregister(GPIOSHIFTDRIVER_NB_CB, 0, destroyGPIOshiftDriver,
"GPIOShiftDriver");
1884 OBJ_GPIOI2C_SCOL = OBJregister(GPIOI2C_NB_CB, 0, destroyGPIOi2c,
"GPIOI2C");
1885 OBJ_GPIOPCA9685_SCOL = OBJregister(GPIOPCA9685_NB_CB, 0, destroyGPIOpca9685,
"GPIOPca9685");
1886 OBJ_GPIOECHO_SCOL = OBJregister(GPIOECHO_NB_CB, 0, destroyGPIOecho,
"GPIOecho");
1888 k = PKhardpak2(m,
"RPIGPIO.pkg",
sizeof(rpiGPIOEngine) /
sizeof(rpiGPIOEngine[0]), rpiGPIOEngine);
1889 MMechostr(MSKDEBUG,
" > Successfully Loaded\n\n");
1898extern "C" SCOL_EXPORT
int ScolLoadPlugin(mmachine m, cbmachine w)
1900extern "C" SCOL_EXPORT
int ScolGPIOLoadPlugin(mmachine m, cbmachine w)
1913extern "C" SCOL_EXPORT
int ScolUnloadPlugin()
1915extern "C" SCOL_EXPORT
int ScolGPIOUnloadPlugin()
int _GPIOlcdCursor(mmachine m)
_GPIOlcdCursor : This function change the cursor state On/Off of an lcd display
int _GPIOi2cRead16(mmachine m)
_GPIOi2cRead16 : This function read the value on a GPIO I2C device 16bits register
int _setGPIOpinPullMode(mmachine m)
_setGPIOpinPullMode : This function set the pull-up or pull-down resistor mode on a GPIO pin
int _GPIOanalogRead(mmachine m)
_GPIOanalogRead : This function read an analogic value on a GPIO pin
int _GPIOpca9685Read(mmachine m)
_GPIOpca9685Read : This function read the value on a GPIO I2C PCA9685 device
int _GPIOlcdDisplay(mmachine m)
_GPIOlcdDisplay : This function change the display state On/Off of an lcd display
int _GPIOpwmWrite(mmachine m)
_GPIOpwmWrite : This function write a value on a PWM GPIO pin (pin 18 on RPI), use softPWM for other ...
int _crGPIOservo(mmachine m)
_crGPIOservo : This function create a GPIO servo motor object
int _GPIOlcdHome(mmachine m)
_GPIOlcdHome : This function set the cursor to home state on lcd display
int _GPIOlcdCursorBlink(mmachine m)
_GPIOlcdCursorBlink : This function change the cursor blink state On/Off of an lcd display
int _crGPIOecho(mmachine m)
_crGPIOecho : This function create a GPIO echo object It allows to read a sensor value with a trigger...
int _GPIOlcdClear(mmachine m)
_GPIOlcdClear : This function clear an lcd display
int _GPIOi2cWrite8(mmachine m)
_GPIOi2cWrite8 : This function write a value on a GPIO I2C device 8bits register
int _dsGPIOecho(mmachine m)
_dsGPIOecho : This function destroy a GPIO echo object
int _GPIOpca9685Reset(mmachine m)
_GPIOpca9685Reset : This function reset a GPIO I2C PCA9685 device
int _GPIOi2cWrite(mmachine m)
_GPIOi2cWrite : This function write a value on a GPIO I2C device
int _GPIOdigitalWrite(mmachine m)
_GPIOdigitalWrite : This function write a high or low value on a GPIO pin
int _dsGPIOpin(mmachine m)
_dsGPIOpin : This function destroy a GPIO pin object
int _crGPIOi2c(mmachine m)
_crGPIOi2c : This function create a GPIO I2C object
int _GPIOpca9685SetFrequency(mmachine m)
_GPIOpca9685SetFrequency : This function change the PWM frequency on a GPIO I2C PCA9685 device
int _GPIOlcdPosition(mmachine m)
_GPIOlcdPosition : This function set the cursor position for next text input of an lcd display
int _GPIOanalogWrite(mmachine m)
_GPIOanalogWrite : This function write an analogic value on a GPIO pin
int _crGPIOshiftDriver(mmachine m)
_crGPIOshiftDriver : This function create a GPIO shift driver, it can change a shift register values ...
int _dsGPIOpca9685(mmachine m)
_dsGPIOpca9685 : This function destroy a GPIO I2C PCA9685 object
int _GPIOpca9685Write(mmachine m)
_GPIOpca9685Write : This function write a value on a GPIO I2C PCA9685 device
int _GPIOi2cRead(mmachine m)
_GPIOi2cRead : This function read the value on a GPIO I2C device
int _GPIOi2cWrite16(mmachine m)
_GPIOi2cWrite16 : This function write a value on a GPIO I2C device 16bits register
int _dsGPIOshiftDriver(mmachine m)
_dsGPIOshiftDriver : This function destroy a GPIO shift driver object
int _GPIOdelayMicroseconds(mmachine m)
_GPIOdelayMicroseconds : This function make a delay in microsecond
int _dsGPIOlcd(mmachine m)
_dsGPIOlcd : This function destroy a GPIO LCD object
int _GPIOlcdPuts(mmachine m)
_GPIOlcdPuts : This function add text at the current cursor position of an lcd display
int _getGPIOechoValue(mmachine m)
_getGPIOechoValue : This function read the distance of an echo object
int _crGPIOpin(mmachine m)
_crGPIOpin : This function create a GPIO pin object
int _GPIOi2cRead8(mmachine m)
_GPIOi2cRead8 : This function read the value on a GPIO I2C device 8bits register
int _GPIOdelay(mmachine m)
_GPIOdelay : This function make a delay in millisecond
int _setGPIOshiftDriverValues(mmachine m)
_setGPIOshiftDriverValues : This function set a servo motor angle
int _dsGPIOi2c(mmachine m)
_dsGPIOi2c : This function destroy a GPIO I2C object
int _crGPIOpca9685(mmachine m)
_crGPIOpca9685 : This function create a GPIO I2C PCA9685 object
int _setGPIOservoAngle(mmachine m)
_setGPIOservoAngle : This function set a servo motor angle
int _dsGPIOservo(mmachine m)
_dsGPIOservo : This function destroy a GPIO servo motor object
int _GPIOdigitalRead(mmachine m)
_GPIOdigitalRead : This function read a high or low value on a GPIO pin
int _crGPIOlcd(mmachine m)
_crGPIOlcd : This function initialize a 4bits or 8 bits display based in Hitachi (HD44780U)