User Tools

Site Tools


en-us_commands:reference:isetcount

This is an old revision of the document!


IsetCount()

IsetCount() changes the current value of the specified counter.

IsetCount command operation flow

void IsetCount(uint8_t counter_id, int32_t value)

Commands

Command Arguments Return Value Operation
IsetCount(counter_id, value) uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t range
int32_t value
void Changes the current value of the specified counter.

Example

const uint8_t COUNTER_ID = 4;
const int32_t BATCH_SIZE = 100;
 
void setup() {
  Serial.begin(115200);
  IsetCount(COUNTER_ID, 25);  // Change the specified counter's current value.
}
 
void loop() {
  const bool itemSensor = 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 resetButton = 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 done = Ictu(COUNTER_ID, itemSensor, resetButton, BATCH_SIZE);  // Count rising input edges and return true when the preset is reached.
  digitalWrite(32, done ? 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/isetcount.1788791735.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki