Frossky 发布的文章

官方文档:
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?

核心名 带外围名称 CPU类型 无线类型
ESP8285 ESP8266 Xtensa 2.4G WIFI
ESP8684 ESP32-C2 RISC-V 2.4G WIFI+BLE5
ESP8686/8685 ESP32-C3 RISC-V 2.4G WIFI+BLE5
-- ESP32-C5 RISC-V 2.4G/5G WIFI6+BLE5
-- ESP32-C6 RISC-V 2.4G WIFI6+BLE5+IEEE 802.15.4
-- ESP32-C61 RISC-V 2.4G WIFI6+BLE5
-- ESP32-P4 RISC-V
-- ESP32-H2 RISC-V BLE5+IEEE 802.15.4
-- ESP32-S2 Xtensa 2.4G WIFI
-- ESP32-S3 Xtensa 2.4G WIFI+BLE5
-- ESP32 Xtensa 2.4G WIFI+BLE
系列名称 功能
P系列 片上温感,jpeg编解码,isp(图像信号控制器如摄像头),camera,
H系列 片上温感
C系列 片上温感
S系列 触摸,片上温感,SDIO, DAC
32系列 SPI,SDIO, DAC

通用功能(包括P/H/C/S/32系列):

  • Sigma Delta DAC
  • SPI
  • RMT红外遥控(C2不支持)
  • PCNT计数器
  • mcpwm电机PWM(C2不支持)
  • LEDC(即LED PWM控制)
  • LCD屏幕,支持I2C/i80/mipi_dsi/rgb_panel/spi.
  • I2S(C2不支持)
  • I2C
  • GPIO
  • 软I2C/软SPI/软Uart
  • ADC

似乎比较靠谱的是mongoDB atlas和google的firebase. mongoDB atlas也是基于azure aws google的云服务的,估计需要选择其一。google的firebase在国内官网居然是可以访问的,但就是无法登录购买。这意思是google部分服务国内可用?
如果在腾讯云阿里云上正儿八经的买个数据库服务,起步价一年最少都是好几千的。
我的需求是本地使用indexedDB存储,并且与云端同步。似乎pouchDB https://pouchdb.com/ 很好满足这个任务,因为他号称可以与couchDB同步,并且本地是使用indexedDB存储的。
其他简化indexedDB的js库包括

下载: https://github.com/filebrowser/filebrowser
文档: https://filebrowser.org/
以前一直用npm库http-server做简单的文件浏览, 以及远程下载, 也http-server也支持https, 对于页面测试是足够了. 不过最近有远程查看图片的需求, 想先看是哪些再下载. 本来用cursor写了一个python版本的, 无奈需求略显复杂以后就有一些bug和效率问题. 想看网上有没有现成的, 觉得这应该是一个广泛需求, 就找到了filebrowser.
文档里的安装其实不如直接下载更方便, 但文档里的配置可以看下.
下载后, 在当前目录运行时, 会自动新建.db文件, 直接访问http://127.0.0.1:8080就可以 ,用户名密码默认都是admin
但此时不允许外部地址访问, 运行filebrowser config set -a 0.0.0.0就可以了. config存在db文件里.
注意, filebrowser 会在运行的每一个目录都生成db文件, 所以直接运行在根目录就好了.
db文件似乎不会存储文件索引之类的信息, 更不会存储缩略图, 所以比文件比较多,图片比较多的文件夹访问比较慢. 我的手机相机文件夹打开大概就需要20秒

优点不说了, 需要说说这个AI助手的主要问题. 大模型使用迄今编程最强的claude 3.5 sonnet

  1. 中文有时候会转成乱码, 尤其在一个对话回合比较多了以后.
  2. cursor默认使用英文作为界面语言, 在一个回合中翻译成中文后,后面做界面修改时,又会写成英文. 并且会呈现不理解中文含义的状态, 已经有的但是中文标识的按键,它会再重复添加一个英文的.
  3. 已经弃用的代码并不一定会删除, 有时候需要明确的指令告诉它删除无用的代码.
  4. 虽然简单的应用中cursor可以一路无脑点确定, 但是如果让cursor代码进行优化重构的时候, 留下的垃圾代码容易在下一个回合中干扰cursor,所以严谨的项目还是应该阅读其代码后再确定.
  5. cursor虽然具有多文件同步编辑的能力, 但是似乎不足以解决复杂的架构问题, 所以似乎还是应该提前进行模块化和模块解耦,让cursor工作在一个模块中, 准确度会更高.

参考https://www.bilibili.com/video/BV1p7H1eyEuY/?spm_id_from=333.788&vd_source=a24e9520e198932372f0c014624cafa4
传统编程,要分工前端后端, 做需求做系统架构, 编码测试.
而Cursor编程, 是做项目提示词.cursorrules, 通过composerCtrl+I创建项目结构, 从基础需求从简单到复杂一步步用自然语言表述, 并转换为代码. 对不满意的部分逐步添加细节.
参考上面教程里的 Cursor 五步

  1. 项目提示词.cursorrules, 建立项目的编程规范, 项目架构, 参考文档等, 自然语言描述
  2. 创建项目和多文件编写 composerCtrl+ICtrl+Shift+I
  3. 单文件修改 Chat
  4. 部分文件内容修改 Ctrl+K
  5. 编写中提示Tab
    另外提到一个前端AI编写工具 https://v0.dev

Cursor试用非常震撼。我第一次用就想尝试一下一直以来想做的一个东西: 就是通过Chrome浏览器来用蓝牙BLE连接设备。之前在b站上看过Chrome浏览器支持蓝牙的视频, 这对我来说是一个完全不熟悉的新的API。然后就尝试用cursor, 看他的能力如何。竟然从无到有。一两个小时的时间完全编写了一个蓝牙BLE的调试器。从HTML到css到JavaScript。从书写逻辑到页面布局。
看看Cursor的成果吧! BLE Scanner
浏览器去调试BLE设备有一个缺陷, 就是要搜寻的服务必须预先定义。

官方文档
首先需要用openssl创建证书. windows环境下如果找不到openssl, 可以进入bash创建后再exit

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

创建中问好几个name,其中问到common name的时候,要填写127.0.0.1, 其他时候用默认值就可以. 完成后在本目录下会生成证书文件
启动https服务:

http-server -S -C cert.pem

鼠标手一般被叫做腕管综合症。这主要是因为鼠标用的是食指和中指,这两个手指的神经是由腕管中的神经来控制。而我的症状则不一样,是小拇指和无名指。我感觉是因为小拇指的负担太重,打键盘太多导致的。小拇指要负责非常多的按键,再加上enter键这个用很多的按键。
因此我想未来鼠标和键盘可能会被淘汰。即使是在生产力工具中,例如笔记本电脑和台式机。因为鼠标和键盘会带来的身体的健康问题,对手指神经的危害,未来势必会被其他的输入方式所取代。一种方式就是语音输入。但是语音输入的准确度不高,并且无法进行中英文混合的准确输入。这对日常办公打中文倒是没有太大问题,然而对于编码的话就问题比较大,还有就是干扰周围的人,并且对噪音非常敏感。还有一种方式就是通过思维。马斯克正在做的脑机接口如果能应用于普通人,则是一个伟大的进步。现在的脑机接口必须嵌入式植入一个芯片在大脑皮层上面。嗯未来如果要普通人使用,则不能用这种侵入式的方式。
尺神经受压通常指的是尺神经综合征(Ulnar Nerve Compression Syndrome),又称肘管综合征(Cubital Tunnel Syndrome)。它是由尺神经在肘部或前臂受压迫造成的,常见症状和相关治疗方法如下:

症状

  1. 麻木与刺痛

    • 小拇指及无名指的麻木或刺痛感,尤其是在手肘屈曲时更为明显。
  2. 疼痛

    • 肘部内侧或前臂内侧可能感到疼痛,通常伴随刺痛感。
  3. 握力减弱

    • 在抓握物体时,可能会发现握力减弱,影响抓握能力。
  4. 运动障碍

    • 有时可能出现手指协调能力下降,例如难以完成细致的动作(如扣扣子)。
  5. 肌肉萎缩

    • 长期受压可导致小拇指根部或无名指根部肌肉萎缩,使得该区域看上去凹陷。

治疗方法

  1. 非手术治疗

    • 休息:避免重复性的手部和肘部活动。
    • 物理治疗:使用拉伸和加强练习,以恢复正常功能。物理治疗师可以帮助设计个性化的锻炼方案。
    • 护具:佩戴护具(如肘托)以保持肘部在良好的位置,特别是在夜间。
    • 药物治疗:使用非处方的消炎药,如布洛芬等,可以缓解疼痛和炎症。
  2. 手术治疗

    • 如果非手术治疗效果不佳且症状持续加重,医生可能建议进行手术。常见的手术方式包括:
      • 尺神经减压术:通过释放对尺神经的压迫。
      • 尺神经转位术:将尺神经移动到一个更少受压迫的位置。

注意事项

如果您有上述症状,请尽快就医,以便进行专业评估并制定相应的治疗计划。尽早干预有助于改善预后。

虽然尺神经受压和腱鞘炎(Tenosynovitis)都是与手部和腕部相关的疾病,但它们是不同的状况。

尺神经受压

  • 定义:尺神经受压通常指的是尺神经在肘部或前臂位置受到压迫,导致其通行受阻,并引发一系列症状,如麻木、刺痛和疼痛。
  • 症状主要包括:小拇指和无名指的麻木感、掌握力减弱以及肘部内侧疼痛等。

腱鞘炎

  • 定义:腱鞘炎是指肌腱周围的腱鞘发生炎症,导致滑动不畅和疼痛。常见于重复性运动或过度使用导致的肌腱疲劳。
  • 症状主要包括:局部疼痛(通常是在手腕或手指部位)、肿胀、触摸时有压痛感,以及活动受限。

主要区别

  • 病因:尺神经受压通常是由于解剖结构问题(如肘部位的压迫),而腱鞘炎通常与过度使用或外伤有关。
  • 出现位置:尺神经受压症状集中在小拇指和无名指,而腱鞘炎则多集中在关节处,如手腕、拇指根部等。

总结

总之,这两种病症虽有相似之处,但应根据具体的症状及体检结果进行区分。如有疑问或出现相关症状,请咨询医生以获得准确诊断和治疗建议。

一种是页面json不变, 使用css属性position: fixed;,同时规定css属性 top bottom left right.
第二种是可以在页面的json文件中写: "disableScroll": true, 然后再元素上使用css属性position: absolute;,再规定css属性top bottom left right. 这种方式是结合recycle-view来用的, 原因太久不太记得了, 似乎因为Recycle-view的一些特性导致position:fixed不能正常固定或页面不能正常滚动.

进入一个页面有几种方式: navigateTo,navigateBack, 熄屏再显示(从其他应用切换回来也是类似).
GPT给的建议是通过app.globalData存储全局变量来判断, 或者用storage存储判断, 感觉都不优雅, 把单个页面问题的解决扩展到了全局去了. 但目前还没有其他好办法, 因为navigateBack和熄屏再显示都是触发onHide,所以无法区分.
GPT还给了一个幻觉建议, 说onShow会带形参进来,判断形参就可以, 但事实上onShow不会带任何形参
通过navigateTo,navigateBack从其他页面导航到这个页面, 通常都需要更新页面数据. 因为上一页导航过来, 这一页的数据还没有生成过; 从下一页返回, 可能在下一页对数据做了更新.

因为CSS的flex每次用的时候总是忘记, 这儿总结一下:
将flex理解为一个画框(父元素)里面的元素(子元素)的排列.
父元素设置整体遵从的规则, 子元素设置个别规则.
总体规格包括:

  • flex-direction: 确定主轴方向. 元素是沿着主轴方向依次放置的. 交叉轴(副轴)即主轴的垂直轴, 确定一行主轴放不下的元素,下一行放的方向.
  • flex-wrap: 元素在主轴放不下, 要不要回车放在下一行.
  • justify-content: 确定元素主轴排列, 以及元素间距
  • align-items: 确定副轴的元素排列
  • align-content: 确定wrap后多行的元素怎么放置,以及行间距等.

银行送了10元京东E卡,进了京东APP完全找不到绑定的地方, 搜索兰搜索京东E卡也只是给了一堆的卖E卡的连接. 说是付款的时候京东自营商品可用, 然后下了好几个单,专门找京东自营,充话费,京东超市和京喜自营买纸巾,付款的时候都没有选择E卡的界面. 找了一圈只好问机器客服, 这才找到绑卡的地方: 我的钱包-点击查看全部-礼品卡,此时注意不要点那个大大的京东E卡图标, 而要点击绑定新卡! 然后输入卡的密码, 只用输入密码, 而不用输入卡号, 虽然给了卡号但并没有什么用.
然后, 我去找下单但没有付款的链接, 还是不能选择! 接着下新单, 也没有选E卡的地方! 我勒个去, 赶快百度找下经验, 发现百度经验这个下单支付界面怎么和我不一样? 终于发现了, 原来从购物车购买,点击去结算才有这个选礼品卡(京东卡/E卡)订单界面, 这个订单界面选择地址, 查看订单详情,选择开票等等.
从商品链接直接购买真的不能选择吗? 我又研究了下,发现不是的!商品链接里面直接点击下单购买(这个名字在不同的商品链接还不一样, 有的叫到手价购买, 有的叫立即购买预估), 这时候不会转到新页面,而是从下方弹出来一个半屏, 上面显示收货地址,选择商品数量和规格, 平常这个时候就选"支付"了, 但注意, 这个半屏是可以上滑的! 你如果上滑一点点, 发现滑出来的只是其他商品的广告, 但如果继续上滑, 才出现商品价格详情,支付方式,发票,留言...等等这些订单信息, 全部堆在这个半屏的最下面, 跟从购物车结算的订单界面是类似的. 但是等等, 为什么礼品卡的选择消失了? 哈哈,这时候还要去选择商品金额栏目里的四个灰色小字:展开更多,才看得到优惠券礼品卡两个选项,不得不说比购物车结算订单界面要隐蔽得多.
京东这个界面设计真的很滑头, 其逻辑是想方设法让你别用券直接支付, 让你确认地址/品类/数量这些最重要信息后就直接付款, 这样 一方面京东拿到最多的钱, 另一方面你买了以后即使想到有优惠券, 也只能下次用了, 又引诱你下次继续在京东购物. 之前几次买东西找不到开票的地方也是这个原因.

引用自定义组件

组件名 组件json-> 页面json-> 页面wxml
mycomp.js/.json/.wxml/.css {"component": true,usingComponents": {}} {"usingComponents": {"mycomp": "../../components/mycomp/mycomp"}} <mycomp></mycomp>

组件展现页面的数据和自身的数据

没有区分. 如

`Component({
  properties: {propFromPage: 1},
  data: {propFromData: 2}
})

在组件wxml中都是同样方式引用{{propFromPage}} {{propFromData}}. 但在组件js中引用方式有区分:this.properties.propFromPage, this.data.propFromData

调用函数

组件中的函数引用方式在js中不需要加methods, 如

`Component({
  properties:{prop:{type: Number, value:1, observer(newValue, oldValue){this.f1();}}},
  lifetimes:{attached(){this.f1();}},
  methods: {
    f1(){},
    f2(){this.f1()},
  }
})

页面向组件传数据

页面js-> 页面wxml-> 页面wxml 组件js
Page({data:{pageprop: 1}}) <mycomp prop="{{pageprop}}"></mycomp> {{prop}} Component({ properties: {prop: 默认值}, methods:{f(){this.properties.prop },}})

组件向页面传数据(通过事件)

组件js-> 页面wxml-> 页面js
Component({method:{f(){this.triggerEvent('someevent', somevalue) },}}) <mycomp bind:someevent="processIt"></mycomp> processIt(e){let value = e.detail}