사용자 도구

사이트 도구


commands:reference:isetcount

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

commands:reference:isetcount [2026/09/01 20:04] – 만듦 - 바깥 편집 127.0.0.1commands:reference:isetcount [2026/09/08 00:53] (현재) – 바깥 편집 127.0.0.1
줄 11: 줄 11:
 ^ 명령어 ^ 인수 ^ 반환값 ^ 동작 ^ ^ 명령어 ^ 인수 ^ 반환값 ^ 동작 ^
 | ''IsetCount(counter_id, value)'' | ''uint8_t counter_id'' — 카운터 번호. ''uint8_t'' 범위이므로 ''0'' ~ ''255'' 사용 가능\\ ''int32_t value'' | ''void'' | 지정한 카운터의 현재값을 변경합니다. | | ''IsetCount(counter_id, value)'' | ''uint8_t counter_id'' — 카운터 번호. ''uint8_t'' 범위이므로 ''0'' ~ ''255'' 사용 가능\\ ''int32_t value'' | ''void'' | 지정한 카운터의 현재값을 변경합니다. |
 +
  
 ===== 예제 ===== ===== 예제 =====
  
 <code cpp> <code cpp>
-bool Ictu(uint8_t counter_id, bool CU, bool RESET, int32_t PV)+const uint8_t COUNTER_ID = 4; 
-bool Ictd(uint8_t counter_id, bool CD, bool LOAD, int32_t PV); +const uint8_t PRESET_BUTTON_PIN = 0; 
-bool Ictud(uint8_t counter_id, bool CU, bool CD, bool RESET, bool LOAD, int32_t PV)+const int32_t PRESET_COUNT = 25
-int32_t IgetCount(uint8_t counter_id); + 
-void IsetCount(uint8_t counter_idint32_t value); +void setup() { 
-bool IctudDownState(uint8_t counter_id);+  Serial.begin(115200); 
 +
 + 
 +void loop() { 
 +  const bool presetButton = digitalRead(PRESET_BUTTON_PIN) == HIGH; 
 +  static bool previousButton = false
 + 
 +  if (presetButton && !previousButton{ 
 +    IsetCount(COUNTER_IDPRESET_COUNT);  // 지정한 카운터의 현재값을 변경합니다. 
 +    Serial.println(F("counter preset to 25")); 
 +  } 
 +  previousButton = presetButton; 
 +}
 </code> </code>
  
 ===== 주의사항 ===== ===== 주의사항 =====
  
-''IN'', ''OUT''''CU'', ''CD''는 상승 순간에 동작합니다. 각 카운터·버퍼에 고유한 ''id''를 사용하고 ''size''는 필요한 범위로 작게 설정하십시오.+  * 기존 0~31 고정 제한은 제거되었다. 단인수 타입이 ''uint8_t''이므로 최대 ID는 ''255''다. 
 +  * 메모리가 부족해서 카운터 상태를 확보하지 못하면 카운터 명령어는 ''false'' 또는 ''0''을 반환다. 
 +  * 한 번 생성된 카운터 상태는 프그램 실행 중 유지된다. 
 + 
 +===== 같은 카테고리의 내장 명령어 ===== 
 + 
 +  * [[commands:reference:ictu|Ictu() 상세 설명 보기]] 
 +  * [[commands:reference:ictd|Ictd() 상세 설명 보기]] 
 +  * [[commands:reference:ictud|Ictud() 상세 설명 보기]] 
 +  * [[commands:reference:igetcount|IgetCount() 상세 설명 보기]] 
 +  * [[commands:reference:ictuddownstate|IctudDownState() 상세 설명 보기]]
  
 [[commands:builtin|← 내장 명령어 리스트]] [[commands:builtin|← 내장 명령어 리스트]]
  
commands/reference/isetcount.1788260660.txt.gz · 마지막으로 수정됨: 저자 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki