You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

3 months ago
  1. #if 0
  2. typedef struct {
  3. uint8_t pid;
  4. uint16_t bid;
  5. int32_t oldPosX;
  6. int32_t oldPosY;
  7. bool isVis;
  8. bool isPosInited;
  9. bool isUsed;
  10. } component_info_t;
  11. component_info_t component_info[100] = {0};
  12. static component_info_t* findComponent(uint8_t pid, uint16_t bid) {
  13. for (size_t i = 0; i < 100; i++) {
  14. if (component_info[i].isUsed && component_info[i].pid == pid && component_info[i].bid == bid) {
  15. return &component_info[i];
  16. }
  17. }
  18. return NULL;
  19. }
  20. static component_info_t* allocComponent(uint8_t pid, uint16_t bid) {
  21. for (size_t i = 0; i < 100; i++) {
  22. if (!component_info[i].isUsed) {
  23. component_info[i].isUsed = true;
  24. component_info[i].pid = pid;
  25. component_info[i].bid = bid;
  26. return &component_info[i];
  27. }
  28. }
  29. return NULL;
  30. }
  31. static component_info_t* forceFindComponent(uint8_t pid, uint16_t bid) {
  32. component_info_t* info = findComponent(pid, bid);
  33. if (info == NULL) {
  34. info = allocComponent(pid, bid);
  35. }
  36. return info;
  37. }
  38. bool UIControler::visEx(uint16_t pid, uint16_t bid, bool val) {
  39. component_info_t* component = forceFindComponent(pid, bid);
  40. if (component == NULL) {
  41. ZLOGW(TAG, "visEx failed,component alloc failed");
  42. return false;
  43. }
  44. bool suc = false;
  45. do {
  46. if (val) {
  47. // ��ʾ
  48. } else {
  49. // ����
  50. if (!component->isPosInited) {
  51. suc = readInt(pid, bid, &component->oldPosX);
  52. if (!suc) break;
  53. suc = readInt(pid, bid + 1, &component->oldPosY);
  54. }
  55. }
  56. } while (false);
  57. }
  58. #endif