2024年10月

示例项目配置

  1. 需要选择target为esp32c2
  2. 需要menuconfig配置flash容量和XTAL晶振。如果串口只能通过74880连接,说明晶振是26Mhz的,如果可以通过115200连接,则晶振是40MHz的。Flash如果配置不对,模组上电后会打印警告。晶振配置不对,蓝牙会找不到。我在淘宝买的这个https://item.taobao.com/item.htm?_u=ed01qc68e7&id=733669672310晶振就是26MHz、4M Flash,详情页说了4M Flash但是没有说26Mhz晶振。而Menuconfig默认配置是40Mhz+2MFlash。
  3. 下载乐鑫提供的配网APP。这个APP默认不会请求权限,需要自己去设置里面打开定位、蓝牙、附近设备等各项权限。
  4. APP打开后就能看到BLUFI DEVICE设备。

小程序实现

参考如下项目:
https://gitee.com/weijian.kang/esp-blufi-for-wx
该项目与上面的示例项目可以配网。不过仍存在一些问题,实际使用时候需要解决:
1、设备列表没有过滤,所有的蓝牙设备都会被扫描出来而不仅仅是blufi设备
2、错误的ssid和密码会导致界面卡在wx.showLoading界面。当然也可能是固件没有返回错误。
3、异步代码采用回调方式,回调地狱现象比较严重。最多的一行代码前面有42个空格(21个tab)
4、中文ssid发送的不对,在串口putty上显示的是乱码,而乐鑫官方发送的ssid在putty上显示正常
5、ssid需要手动输入
这个项目参考的另一个项目是
https://github.com/xuhongv/BlufiEsp32WeChat
这个项目readme虽然说只支持esp32,但esp32c2实测也是支持的。
似乎前面一个项目存在的问题都存在,只是功能似乎更强一些包括:
1、增加了本地ssid扫描和选择,根据界面提示是模组扫描的结果,但扫出来的wifi数量明显不足。
2、可在配网同时发送自定义的数据。但在putty打印上没有显示。当然这也可能是固件没有处理的原因。

官方文档:
https://freertos.org/Documentation/02-Kernel/02-Kernel-features/02-Queues-mutexes-and-semaphores/02-Binary-semaphores
https://freertos.org/Documentation/02-Kernel/02-Kernel-features/02-Queues-mutexes-and-semaphores/03-Counting-semaphores

信号量semaphore词源

semaphore除了表示信号量,还有旗语的意思。组成包括:

  • sema- 语义、符号/sign 的含义。如语义化版本Sematic Version,语义学Semasiology
  • phor- 带来/bring, 如欣快的euphoric, 隐喻metaphor, 发光体luminophor

组合起来表示带来信号。

信号量的使用

B站上有个信号量机制讲解视频https://www.bilibili.com/video/BV18P41187NV
信号灯(交通灯)就是一种信号量,在不同方向的汽车要使用同一个交叉路口的时候, 在同一时间,信号灯只允许某一方向的汽车通行。
在FreeRTOS中, 获取一个信号量即take,释放一个信号量即give。获取信号量相当于这个任务来到了十字路口,如果没有获取到信号量他就在十字路口这里等着,直到等到了信号量再继续执行。释放信号量可以在获取信号量的任务本身中进行,也可以在中断和回调中进行。
binary信号量是指只能取0或者1,counting信号量可以取大于1的值。
综合来说,信号量起到了和JavaScript的promise、await类似的作用。take相当于await等待。give相当于在promise的fullfilled。等待信号量释放的过程,相当于是等待另外一个异步程序执行完毕的过程。和await类似,避免了JavaScript的回调地狱,将异步函数执行完毕后需要做的操作仍然放在本任务中而不是放在回调后面。
对于有限的资源,JavaScript需要自行去实现信号量的计数,而freeRTOS直接提供了信号量。
下面是esp-idf的ledc fade渐变调光的示例代码,截取了其中和信号量有关的代码,以便说明。部分代码顺序略有调整,但不影响实际的代码工作逻辑。

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "driver/ledc.h"
#include "esp_err.h"
/*
* ....... 省略代码
*/
// 这是渐变调光结束后注册的用户回调函数。其中释放give了用于监控回调是否完成的信号量。user_arg在这个回调函数注册的时候传入了信号量。
static IRAM_ATTR bool cb_ledc_fade_end_event(const ledc_cb_param_t *param, void *user_arg)
{
    BaseType_t taskAwoken = pdFALSE;

    if (param->event == LEDC_FADE_END_EVT) {
        SemaphoreHandle_t counting_sem = (SemaphoreHandle_t) user_arg;
        xSemaphoreGiveFromISR(counting_sem, &taskAwoken);
    }

    return (taskAwoken == pdTRUE);
}

void app_main(void)
{
/*
* ....... 省略代码
*/
    // 在主程序中注册了计数信号量,数字为要调光的led的通道数量。最后一个参数零表示计数信号量的起始值为0,也就是没有任何资源。
    SemaphoreHandle_t counting_sem = xSemaphoreCreateCounting(LEDC_TEST_CH_NUM, 0);
    // 在这儿注册led调光结束的回调函数, 并且将计数信号量作为用户参数也传入比较函数中。 
    ledc_cbs_t callbacks = {
        .fade_cb = cb_ledc_fade_end_event
    };
    for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
        ledc_cb_register(ledc_channel[ch].speed_mode, ledc_channel[ch].channel, &callbacks, (void *) counting_sem);
    }
    while (1) {
        // 在主程序中会循环调亮调暗的过程。先调亮到LEDC_TEST_DUTY,再调暗到0
        printf("1. LEDC fade up to duty = %d\n", LEDC_TEST_DUTY);
        for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
            ledc_set_fade_with_time(ledc_channel[ch].speed_mode,
                                    ledc_channel[ch].channel, LEDC_TEST_DUTY, LEDC_TEST_FADE_TIME);
            ledc_fade_start(ledc_channel[ch].speed_mode,
                            ledc_channel[ch].channel, LEDC_FADE_NO_WAIT);
        }
        // 因为上面的渐变调光函数事实上会调用异步任务或者中断函数ISR执行,完全执行需要时间,所以这里先取走了所有的信号量。因为起始的信号量为零,需要等待所有调光完成回调函数释放信号量后才能继续执行。
        for (int i = 0; i < LEDC_TEST_CH_NUM; i++) {
            xSemaphoreTake(counting_sem, portMAX_DELAY);
        }
        // 下面又从最高的亮度调为零,与上面类似,通过take信号量的方式等待调光执行完成。
        printf("2. LEDC fade down to duty = 0\n");
        for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
            ledc_set_fade_with_time(ledc_channel[ch].speed_mode,
                                    ledc_channel[ch].channel, 0, LEDC_TEST_FADE_TIME);
            ledc_fade_start(ledc_channel[ch].speed_mode,
                            ledc_channel[ch].channel, LEDC_FADE_NO_WAIT);
        }

        for (int i = 0; i < LEDC_TEST_CH_NUM; i++) {
            xSemaphoreTake(counting_sem, portMAX_DELAY);
        }
/*
* ....... 省略代码
*/
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

三年级上-Unit 1 How do we feel?

In this unit, you will:

  • Be able to describe how you feel.
  • Be able to talk about different feelings.

Get ready

Think: What feelings do we have?

A. Listen. Then point and say.

happy
sad
angry
tired

B. trace and match.

C. Build background Feelings

We have different feelings.
Look and draw.
How are you?
In this story, the children have different feelings in class.
Social science

Explore

How are you?

1
Teacher: Good morning, boys and girls! How are you?
2
Wen Jie: Not so good. I'm cold.
Teacher: OK, Wen Jie. Let's close the window.
3
Jia Li: I'm sad. I can't find my pencil.
Teacher: Look, Jia Li. Here's a pencil.
4
Teacher: What about you two?
Another Girl: I'm happy.
Another boy: I'm happy, too!
5
Teacher: well, let's start again. How are you?
Students: Fine, thank you.
Teacher: Phew! Now please look at the blackboard...

A. Look and choose.

a. Here's a pencil.
b. Let's close the window.

B. Read and act.

How are you, Wen Jie?
Not so good, I'm...

Think: How do you feel in class?

C. Listen and chant.

How are you?
How are you? How are you?
How are you this morning?
I'm fine. I'm fine.
You are very kind.
How are you? How are you?
How are you this afternoon?
Very good. Very good.
I'm very good.

Learn

How are you?
I'm fine.
I'm happy.

D. Ask and answer.

A: How are you?
B: Not so good. I'm tired. How are you?
A: I'm happy..

Communicate

A. Listen and number. Then act.

Li Chen's day
A: How are you? Li Chen?
B: I'm ...

Think: How are you today?

B. Do a role-play.

Children at the beach
A: How are you, Lulu?
B: Oh, not so good. I'm tired.

C. Trace draw and say.

Extend

A thirsty bird

1
Bird: I'm thirsty.
2
Bird: Water!
3
Bird: I can't drink the water.
The bird is sad.
4
Bird: I have a good idea!
5
Bird: I can drink the water now!
Look! the bird is happy.

Think: how do you make yourself feel better?

Unit 2. What's interesting about families?

In this unit, you will:

  • Be able to explain what is interesting about families.
  • Be able to talk about families and family members.

Get ready

Think: who is in your family?

A. Listen, then point and say.

Grandfather, grandmother, father, mother, sister, brother, and me.

B. Trace and match

C. Build background families

We live in families. We love each other.

Listen and number.

Preview families.

In this text, we learn about different families.

Explore

Families

My name is Linlin. This is my family, my mother, father and brother.
My name is Yangyang. This is my family. She's my mother. And he's my father. Who is he? He is Pengpeng, my twin brother.
My name is Xiaoyu. This is my family: my father, mother, brother and sister.
My name is Xiaojie. My family is big. This is my family: my grandfather, grandmother, father, mother and sister.
How are the families different?

A. Look and act

Hi, I'm... This is my...

B. Choose one family and say

Xiaojie family is big. my family is big too.

Think. What is your family like?

C. Listen and chant.

My family

Here is a picture. Come and see.
This is all my family.
Who is she? She's my mother.
Who is he? He's my father.
Who is he? He's my brother.
And what is that? Who is she?
Don't be silly. That is me!

Learn

This is my family.
Who is he? He is my father.
Who is she? She is my mother.

D. Ask and answer.

Family photos
Who is he? He is my father.

Communicate.

A. Listen and number. Then act.

Li Wen's family tree.
Hello, I'm Li Wen. This is my family tree. This is my grandfather. This is...

Think: What is your family tree like?

B. Look at the talk

School news. Family month.

Look at the children with their families. They are happy.
Who is he, Li Wen? He's my brother.

C. Trace stick and say.

I am Li Wen. I am happy, too.

Extend

At the mid-autumn festival

This is the mid-autumn festival. Lanlan and her brother Junjun are at their grandparents' house.
1
Junjun: Look, Lanlan!
Lanlan: Wow!
Junjun: Who is he?
Lanlan: He's our grandpa.
Junjun: Who is she?
Lanlan: She's our grandma.
2
Lanlan: Grandpa, is this my dad?
Grandpa: Yes, that's your father. It's our mid-autumn festival photo.
3
Dad: Hey, let's take a photo together.
Lanlan: Good idea!

Unit 3. What do we look like?

In this unit, you will:

  • Be able to explain what people look like.
  • What you talk about what you look like.

Get ready

Think: What body parts do we have?

A. Listen, then point and say.

Hair, head, ear, eye, face, nose, mouth.

Learn

An eye, two eyes, hair

B. Trace and match

C. Build background. Our looks

People look different. But we may look like people in our families.

Look and see

My mother and I have big eyes.
Now it's your turn.

Preview.

Minmin‘s haircut.

In this story Minmin's hair is too long. And he gets a great haircut.

Explore

Minmin's harcut

1
Mom: Look at your hair, Minmin it's too long.
Minmin: But I like it!
2
Mom: Minmin, I can't see your eyes. Now sit on this chair, please!
3
Snip! Snip!
4
Mom: Look, do you like your haircut?
5
Minmin: Oh, I have short hair.
6
Minmin: I like my hair cut, mum.
Mom: You look great!
Minmin: Thanks, mom.
What does Minmin Look like before and after his haircut?

A. Read and match

I can see your eyes.
Your hair is too long.
I can't see your eyes.
You look great!

B. Which part of the story do you like? Tick and act.

Oh, I have... I like my hair cut.

Think What do you look like?

C Listen and chant.

Look at my face
Look at my face.
Look at my face.
I have a round face.
Look at my eyes!
Look at my eyes!
I have bright eyes!
Look at my nose.
Look at my nose!
I have a small nose!
Look at my hair!
Look at my hair!
I have long black hair.

Learn

I have a small nose.
I have big eyes.
I have long hair.

D Look and act

Look, I have a big head. I have ...

Communicate

A. Listen and number. Then talk.

Who am I?

Play a guessing game.

Think: What does your best friend look like?

B. Do a Survey.

Hi, Lili. What do you like about yourself?
I like my hair. I have long hair.

Trace draw and say

I'm Lili. I like my hair.

Extend

People look different

People around the world look different.
Some people have brown eyes, some have blue eyes.
Some people have black hair. Some have brown hair.

What do you like?
Do you have long or short hair?
Do you have a big or small mouth?

People look different.
It's OK to be different.

Unit 4 How do we have fun?

In this unit, you will:

  • Be able to explain how you have fun.
  • Be able to talk about some fun activities.
  • Be able to write about having fun with others.

    Listen, then point and say.

    Think: What do we do for fun?
    Skip, run, fly a kite, skateboard, ride a bike.

    Build background. Having fun.

    We have fun with our family and friends.

    Look, think and say

    This is my father. We skip together..

    Preview

    In the park.
    In this story, a group of children have fun in the park.

    Explore

    In the park

    1
    The children are in a park.
    Children: Hello, Tingting.
    Tingting: Hello.
    2
    Yaoyao Can fly a kite! She is happy! Chenchen can ride a bike, but he is too fast.
    Chenchen: It's fun. Woo hoo!
    3
    Chenchen: Oh no!
    Huihui can run fast and help Chenchen.
    4
    Now the children want to stip together, but tingting can't skip.
    Chenchen: Hey, let's skip together.
    Children: OK!
    Tingting: I can't skip, but I can get some juice. Are you thirsty?
    5
    Tingting can skateboard. She brings some juice.
    Dangdang: Wow, Tingting! Thank you!
    How do the children have fun in the park?

    A. Read and order

    Tingting brings some juice.
    Yaoyao can fly a kite.
    The children skip together.
    Huihui can help Chen chen.

    B. Read match and say.

    I can run fast.
    I can fly a kite.
    I can ride a bike.
    I can skateboard.
    I can skip.
    Yaoyao can...
    Think: How do you have fun with your friends?

    C Listen and chant.

    I can ...

    I can't fly up in the sky,
    but I can fly a kite up high.
    I can't ride a bike at all,
    but I can play football.
    I can skip and I can run.
    And I can jump -- it's fun!

    Learn

    I can skip. I can't skateboard. Painting can skateboard. She can't skip.

    D Tick and talk.

    I can... I can't...
    ... can ...
    He/She can't ...

    Communicate.

    A. Listen and circle, then talk.

    Let's have fun together.
    What can Tiantian/Xiaoxiao do in the park?
    He/She can ...
    Think: How do you have fun with your family?

    B. Think and say

    A sports day notice.

    Time: Friday afternoon, one PM to three PM.
    Place: The sports ground
    You can ...

  • skip
  • run
  • jump
    Come with your mom and dad. Let's have fun.
    I can ... My father/mother can ... too. We can ... together.

    C. Trace and write.

    We skip together. We have fun.

    Extend

    Let's play games!

    We play games everyday. We have a lot of fun.
    Jump, jump and jump. One two three. We can play hopscotch. You and me.
    Move the rope round and round. We can skip up and down.
    Two teams can play tug of war, put the rope more and more.

    Think: What games do you like to play? Why?

Unit 5 What do we eat?

In this unit, you will:

  • Be able to describe what do we eat
  • Be able to talk and write about the food and drinks you like

Get ready

Think: What food do we eat every day?

A. Listen, then point and say.

Milk, juice, apple, tomato, carrot, banana, fish, grape, meat.

Learn: Carrot → carrots, tomato → tomatoes

C. Build background Food

We eat food every day. We eat meat, fruit and vegetables.

Think and say.

07:15 Seven fifteen
11:30 Eleven thirty
18:15 Eighteen fifteen
I have carrots and bananas. I have ...

Preview: In this story, the children make Let's cut the fruits and vegetables. We can have some fun. a funny food face.

Explore

A funny food face

  1. Wenwen: What do you have, mum?
    Chenchen: Do you have any apples?
    Mum: Let's see.
  2. Chenchen: There are some fruit and vegetables.
    Wenwen: Oh no! I don't like carrots.
    Mum: Let's cut the fruits and vegetables. We can have some fun.
    3
    Huihui: Do you like carrots, Chenchen?
    Chenchen: No, I don't.
    Mum: Carrots are good for you.
    4
    Mum: What do you like, Huihui?
    Huihui: I like carrots!
    Mum: OK... Carrots for the "eyes".
    5
    Chenchen: I like apples.
    Wenwen: I like bananas.
    Huihui:Ha! Ha! This is fun!
    6
    Chenchen: We like the food face, Mum.
    Mum: That's great.
    What fruit and vegetables do the children eat?

    A. Read and match.

  • The children eat the funny food face.
  • The children make a funny food face.
  • Mum buys some food.
  • The children cut up the fruit and vegetables.

    B. Read and act.

    A: What do you like?
    B: I like...
    Think: What fruits and vegetables do you and your family eat every day?

    C. Listen and chant.

    A Salad
    What do you like?
    I like salad.
    Do you like tomatoes?
    Yes, I do.
    Do you like bananas?
    Yes, I do.
    Do you like chocolate?
    Yes, I do.
    Look! A salad for you.
    Thank you very much.
    Do you like it?
    No, I don't like them together!
    Learn
    What do you like? I like tomatoes.
    Do you like fish? Yes, I do.
    Do you like meat? No, I don't.
    do not → don't

    D. Ask and answer.

    A. Do you like fish? I like...
    B. Yes, I do. What do you like?

Communicate.

A. Listen and tick. Then act.

China Zhong Yu. Thailand Anna. UK Ted.
A: What do you like, Zhong Yu?
B: I like ...

Think: What food from different countries do you know?

B. Look and talk.

In the restaurant.
Menu
fish ¥30
chicken ¥85
tomato soup ¥8
carrots ¥15
apple juice ¥10
grape juice ¥10

Extend

Parts of plants
We eat different parts of plants. Some of the parts are roots, fruit or leaves.

  • Root: Carrots are long and orange.
  • Fruit: Tomatoes are round and red.
  • Leaves: Lettuce is big and green.
    What parts of plants do you like to eat?

    Think: What other parts of plants can we eat?

Unit 6. What do we like about small animals?

In this unit, you will:

  • Be able to describe what you like about small animals.
  • Be able to talk about small animals
  • Be able to write about your favorite small animal.

Get ready

Think: What small animals do you know?

A. Listen, then point and say.

Squirrel, rabbit, cat, dog, frog, mouse.

Learn: dog → dogs, mouse → mice

B. Trees and match.

Pets day

Build background. Small animals

There are many small animals around us. Some of them are our friends.

Preview

Coco's day in the park
In this story, two friends and the dog Coco find different small animals in the park.

Explore.

Coco's day in the park

  1. Boy: It's a nice day today.
    Girl: It is.
    Coco: Woof! Woof!
    Girl: What is it, Coco?
  2. Boy: Oh, it's a cat! Look! it has small ears.
    Girl: It's cute. I like its big eyes.

  3. Coco: Woof! Woof!
    Girl: What is it, Coco?

  4. Boy: Look, that's a squirrel!
    Girl: Is this a squirrel, too?
    Boy: Yes, they have big long tails.

  5. Girl: I see two small animals. What are they?

  6. Girl: Oh, they are frogs. They are small.
    Boy: I like frogs. They eat bad bugs.

    What do the children like about the small animals in the park?

A. Read and order.

They see frogs.
They see squirrels.
They see a cat.

B. Match and talk.

  • They are small.
  • It has big eyes and small ears.
  • They have big long tails.
    A: What is it? What are they?
    B: It's a ... It ... / They're ... They ...

    Think: What small animals do you like? What do you like about them?

    C. Listen and chant.

    What is it?
    What is it?
    What is it?
    It's swimming in the river.
    What is it?
    What is it?
    It's a little frog.
    What are they?
    What are they?
    They are running on the grass.
    What are they?
    What are they?
    They are cute little dogs.

Learn
What is it? It is a mouse. It is → It's
What are they? Are they are rabbits. They are → They're

D. Play a game

What is it? It's a cat.
What are they? They are...

Communicate.

A. Listen and number, then say.

Small animals in grandpa Li's garden
What small animals can you see in grandpa Li's garden?
I can see...
It has/ They have...
It's / They're ...

Think: What does your favorite small animal look like?

B. Play a game

A: It has big eyes and small ears. It has long hair. What is it?
B: It's a cat. That's picture one.

C. Draw trace and write.

A Riddle.
It has big eyes and small ears. It's cute. I like it. What is it?

Extend

A frog's life
It is a small egg. It can't swim or jump.
It is a baby frog. Its tail is long. It can swim.
It is still a baby frog. It has four legs. Its tail is small and short. It can swim and jump.
It is a frog. It has four legs. It has no tail. Its mouth is big. It can swim and jump.

Think: Is a frog's life amazing? What do you like about a frog's life?

Unit 7. What do we know about the weather?

In this unit, you will:

  • Be able to describe different weather.
  • Be able to talk and write about the weather in different places.

    Get ready

    Think: What weather do you know?

    A. Listen, then point and say.

    sunny sun
    windy wind
    rainy rain
    cloudy cloud

    B. Trace write and say

    It's windy in Beijing.

C. Build background Weather

There is different whether. We can do different things in different weather.

Listen tick and say.

It's sunny. I can go to the park.

Preview: We like different weather. In this text, the children and the farmer like different weather.

Explore.

We like different weather.

  1. Girl: How's the weather today?
    Boy: It's rainy.
    Girl: I don't like the rain.
  2. Girl: It's windy today. I like the wind. I can fly my kite.
    Boy: Let's go to the park.
    Girl: Hooray!

  3. Girl: Oh! Dear!
    Boy: It's hot today. I don't like the sun.

Farmer:
I like the rain.
Oh, no! My hat and my plants! I don't like the wind.
I like the song. I have a big harvest. I'm very happy.

What weather do the children and the farmer like? Why?

A. Read and draw.

  1. The rainy day.
  2. The windy day.
  3. The sunny day.

    B. Think and say

  4. It's rainy today. I like...
  5. It's ... today. I like ... I can...

    Think: What weather do you like? Why?

    C. Listen and chant.

    How's the weather?
    How's the weather?
    How's the weather?
    How's the weather today?
    Is it sunny?
    Is it sunny?
    Can we go out and play?
    It's sunny.
    It's sunny.
    It's sunny today.
    We can go to the park.
    Let's go there and play.

Learn
How is the weather? It is windy. How is → How's

D. Make and talk.

Make a weather wheel

Communicate.

A. Listen and choose then say.

How's the weather in your city?
It's sunny. It's snowy.
It's windy. It's rainy.
It's new year's day. In Zhong Yu's city, it's ...

Think How is the weather in the city today?

B. Look and act.

Son: Hi, Dad.
Dad: Hi, how are you and your mum?
Son: We are good. How's the weather in? Shenyang, Dad?
Dad: It's ... here. How's the weather ...?
Son: It's...

Trace and write.

Dad: How's the weather in Sanya?
Son: It's sunny and hot. How's the weather in Shenyang?

Extend

On a windy day.
Woosh! Woosh!
The wind is strong.
My kite goes up.
The string is long.

Oh, no! Oh, no!
It's in the tree!
Please, Mr. Wind.
Don't take it from me.
Woosh! Woosh!
There it goes!
My kite is free.
The strong wind blows.

Think: What can you do on a windy day?