Пример #1
0
void action_print_value(int pin, int value, void *arg) 
{
  DEBUG4_PRINT("Pin ");
  DEBUG4_PRINT(pin);
  DEBUG4_PRINT(" value: ");
  DEBUG4_PRINT(value);
  DEBUG4_PRINT("\n");
}
Пример #2
0
void MCP::publish() {
	DEBUG4_PRINT("MCP.publish");

	for (byte i = 0; i < appSettings.msw_cnt; i++) {
		MCP23017::digitalWrite(appSettings.msw[i], actStates.getMsw(i));
		String strState = (actStates.getMsw(i)?"ON":"OFF");
		if (mqtt)
			mqtt->publish(appSettings.topMSW,i+1, OUT, strState);

		DEBUG1_PRINTF("sw[%d]=", i);
		DEBUG1_PRINT(strState);
		DEBUG1_PRINTLN();
	}
	PRINT_MEM();
	DEBUG4_PRINTLN();

	interruptReset();

}
Пример #3
0
MCP::MCP(MQTT &mqtt, AppSettings &appSettings, ActStates &actStates) : MCP23017(), appSettings(appSettings), actStates(actStates) {
	DEBUG4_PRINT("MCP.create");
	init(mqtt);
}
Пример #4
0
void MCP::interruptCallback() {
	DEBUG4_PRINT("MCP.intCB   ");
	detachInterrupt(appSettings.m_int);
	timerBtnHandle.initializeMs(DEBOUNCE_TIME, TimerDelegate(&MCP::interruptHandler, this)).startOnce();
}
Пример #5
0
/* Initialized the pins of an output */
int hmtl_setup_output(config_hdr_t *config, output_hdr_t *hdr, void *data)
{
  DEBUG4_VALUE("hmtl_setup_output: type=", hdr->type);
  switch (hdr->type) {
    case HMTL_OUTPUT_VALUE: 
      {
        config_value_t *out = (config_value_t *)hdr;
        DEBUG4_PRINT(" value");
        pinMode(out->pin, OUTPUT);
        break;
      }
    case HMTL_OUTPUT_RGB:
      {
        config_rgb_t *out = (config_rgb_t *)hdr;
        DEBUG4_PRINT(" rgb");
        for (int j = 0; j < 3; j++) {
          pinMode(out->pins[j], OUTPUT);
        }
        break;
      }
    case HMTL_OUTPUT_PROGRAM:
      {
        //        config_program_t *out = (config_program_t *)hdr;
        DEBUG4_PRINT(" program");
        break;
      }
#ifdef USE_PIXELUTIL
    case HMTL_OUTPUT_PIXELS:
      {
        DEBUG4_PRINT(" pixels");
        if (data != NULL) {
          config_pixels_t *out = (config_pixels_t *)hdr;
          PixelUtil *pixels = (PixelUtil *)data;
          pixels->init(out->numPixels,
                       out->dataPin,
                       out->clockPin,
                       out->type);
        } else {
          DEBUG_ERR("Expected PixelUtil data struct for pixel configs");
          return -1;
        }
        break;
      }
#endif
#ifdef USE_MPR121
    case HMTL_OUTPUT_MPR121:
      {
        DEBUG4_PRINTLN(" mpr121");
        if (data != NULL) {
          config_mpr121_t *out = (config_mpr121_t *)hdr;
          MPR121 *capSensor = (MPR121 *)data;
          capSensor->init(out->irqPin,
                          out->useInterrupt,
                          START_ADDRESS,  // XXX - Only single address
                          false,          // XXX - No touch times
                          false);         // XXX - No auto enable
          for (int i = 0; i < MAX_MPR121_PINS; i++) {
            byte touch = out->thresholds[i] & 0x0F;
            byte release = (out->thresholds[i] & 0xF0) >> 4;
            if (touch || release) {
              capSensor->setThreshold(i, touch, release);
            }
          }
        } else {
          DEBUG_ERR("Expected MPR121 data struct for mpr121 configs");
          return -1;
        }
        break;
      }