A26_OLED_example.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2022 Jinan Bosai Network Technology Co., LTD Ltd.
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <unistd.h>
  18. #include "OLED_I2C.h"
  19. #include "cmsis_os2.h"
  20. #include "ohos_init.h"
  21. #define TASK_STACK_SIZE 1024 * 8
  22. #define TASK_PRIO 25
  23. static void ExampleTask(void)
  24. {
  25. uint8_t ret;
  26. ret = BoardInit();
  27. if (ret != 0) {
  28. printf("BoardInit failed!\r\n");
  29. return;
  30. }
  31. OLED_Init();
  32. OLED_CLS();
  33. while (1) {
  34. printf("=======================================\r\n");
  35. printf("*************A25_MPU6050_example***********\r\n");
  36. printf("=======================================\r\n");
  37. OLED_ShowStr(0,3,(unsigned char*)"Wildfire Tech",1); //测试6*8字符
  38. OLED_ShowStr(0,4,(unsigned char*)"Hello wildfire",2); //测试8*16字符
  39. usleep(1000000);
  40. }
  41. }
  42. static void ExampleEntry(void)
  43. {
  44. osThreadAttr_t attr;
  45. attr.name = "ExampleTask";
  46. attr.attr_bits = 0U;
  47. attr.cb_mem = NULL;
  48. attr.cb_size = 0U;
  49. attr.stack_mem = NULL;
  50. attr.stack_size = TASK_STACK_SIZE;
  51. attr.priority = TASK_PRIO;
  52. if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
  53. printf("Failed to create ExampleTask!\n");
  54. }
  55. }
  56. APP_FEATURE_INIT(ExampleEntry);