Uploaded by letsgoniners49

report

advertisement
Lab 4 Report
Lab 4.1
Lab 4.1 is a task that involves programming the ESP32C3 board equipped with the
ICM-42670-P sensor to function as a Bluetooth mouse. The primary goal is to make the board
respond to tilting movements by moving the mouse cursor in the X/Y direction. In the exercise,
we must write a program that outputs "UP/DOWN" or "LEFT/RIGHT" or “UP” or “LEFT” in the
terminal using ESP_LOGI, reflecting the board's inclination. For instance, if the board tilts UP
and LEFT simultaneously, it should print "UP LEFT."
Sources: In this portion of the lab I used much of my code from lab 3 which was implementing
the i2c init, read, and write functions. Then using the datasheet for the accelerometer, I wrote an
initialize the accelerometer and one function to read the accelerometer. One Chat GPT query I
used which helped me was “write a function_read accel which determines the inclination of the
board with either UP, DOWN, UP LEFT, UP RIGHT, DOWN RIGHT, DOWN RIGHT. Log this
using ESP_LOGI. Do this by reading the data and determining the x and y data and seeing if it
crossed the specific threshold value”.
Lab 4.2
In Lab 4.2, the primary objective is to modify an existing esp-idf example that involves Bluetooth
communication, shifting its functionality from controlling volume to moving a mouse cursor left
and right across the screen. The task requires us to send mouse movement commands via
Bluetooth, making the cursor move left and right on a connected Raspberry Pi's screen. After
each left-right cycle, the program should pause for 5 seconds.
Sources: Majority of this code was duplicated from the hid_demo_task example found in the
esp-idf examples, specifically at “examples/bluetooth/bluedroid/ble/ble_hid_device_demo”. I
copied this entire folder and made a change in the hid_demo_task function in the main src file of
the demo to instead of control volume, move the cursor left and right. This was done by a simple
GPT query: “using this code [hid_demo] edit the hide_demo_task funcion to instead of
controlling volume to move the mouse left to right on the screen, then pause for 5 seconds.”
Lab 4.3
In this portion of the lab, the task is to integrate the concepts from Labs 4.1 and 4.2, where the
inclination of a board is used to control mouse movement with an added complexity of speed
control. The objective is to create a more nuanced control system for the mouse cursor by
implementing at least two levels of inclination (like "A_BIT_LEFT" and "A_LOT_LEFT"), which in
turn control the speed of the cursor's movement.
Sources: When doing this portion of the lab I quite literally added the 4.1 functions into the 4.2
file. Then I asked chat gpt to change the read_accel function to instead of logging the
inclination, to actually move the cursor accordingly. This query made the mouse move “change
this function to instead of ESP Log, to actually move the mouse” (“this function” refers to the old
read_accel from Lab4.1). Then I asked chat gpt if it followed the lab specifications because I
knew it was missing the alot or a little bit of movement. So I asked chat GPT : “can you adjust
this to match the lab summary” and it added that part. It not at all work smoothly, I still had many
errors, but it did give me a good starting point.
Download