User Tools

Site Tools


en-us_commands:reference:ictd

This is an old revision of the document!


Table of Contents

Ictd()

Ictd() loads the preset value, then decrements the current value at each input rising edge.

Ictd command operation flow

bool Ictd(uint8_t counter_id, bool CD, bool LOAD, int32_t PV)

Commands

Command Arguments Return Value Operation
Ictd(counter_id, CD, LOAD, PV) uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t range
bool CD
bool LOAD
int32_t PV — Preset value
bool Loads the preset value, then decrements the current value at each input rising edge.

Example

const uint8_t COUNTER_ID = 1;
const int32_t START_QUANTITY = 50;
 
void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const bool shipped = IdigitalRead(0, 5);  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state.
  const bool loadQuantity = IdigitalRead(1, 5);  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state.
  const bool empty = Ictd(COUNTER_ID, shipped, loadQuantity, START_QUANTITY);  // Load the preset, then decrement the current value on each rising input edge.
  digitalWrite(32, empty ? HIGH : LOW);
}

Precautions

  • The previous fixed 0~31 restriction has been removed. However, the argument type is uint8_t, so the maximum ID is 255.
  • If insufficient memory prevents allocation of counter state, counter commands return false or 0.
  • Once created, counter state is retained while the program runs.

← Built-in Command List

en-us_commands/reference/ictd.1788791734.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki