• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 
16 #include <stdio.h>
17 #include <stdint.h>
18 #include <string.h>
19 #include <unistd.h>
20 
21 #include "ohos_init.h"
22 #include "cmsis_os2.h"
23 #include "iot_i2c.h"
24 #include "iot_gpio.h"
25 #include "iot_errno.h"
26 
27 #include "oled_ssd1306.h"
28 
29 #define AHT20_BAUDRATE (400 * 1000)
30 #define AHT20_I2C_IDX 0
31 
OledmentTask(const char * arg)32 static void OledmentTask(const char *arg)
33 {
34     (void)arg;
35     OledInit();
36     OledFillScreen(0);
37     IoTI2cInit(AHT20_I2C_IDX, AHT20_BAUDRATE);
38 
39     OledShowString(20, 3, "Hello  World", 1); /* 屏幕第20列3行显示1行 */
40 }
41 
OledDemo(void)42 static void OledDemo(void)
43 {
44     osThreadAttr_t attr;
45     attr.name = "OledmentTask";
46     attr.attr_bits = 0U;
47     attr.cb_mem = NULL;
48     attr.cb_size = 0U;
49     attr.stack_mem = NULL;
50     attr.stack_size = 4096; /* 任务大小4096 */
51     attr.priority = osPriorityNormal;
52 
53     if (osThreadNew(OledmentTask, NULL, &attr) == NULL) {
54         printf("[OledDemo] Failed to create OledmentTask!\n");
55     }
56 }
57 
58 APP_FEATURE_INIT(OledDemo);