תוכן עניינים:

אתגר ממש: 5 שלבים
אתגר ממש: 5 שלבים

וִידֵאוֹ: אתגר ממש: 5 שלבים

וִידֵאוֹ: אתגר ממש: 5 שלבים
וִידֵאוֹ: ניסיתי לחיות יום שלם על ₪5 בלבד! (אתגר בלתי אפשרי!!) 2024, יולי
Anonim
Image
Image
שלב 1: הלחמה של המעגל
שלב 1: הלחמה של המעגל

העולם המודרני מחייב בני אדם לצאת מהגוף ולחיות בתוך הדיגיטל.

עם הופעתו של אל וריבוי הטכנולוגיה אנשים נותנים אמון רב מדי במכונה ומאמינים שהיא תמיד נכונה.

"באמת" נועד לערער את האמון השקרי הזה באמצעות יצירת בדיקת גלאי שקר מזוייפת. אנשים יאמינו בקלות שבאמת עובד אבל כאשר יינתנו תשובות שווא זה יערער את האמון העיוור שלהם בטכנולוגיה.

שלב 1: שלב 1: הלחמה של המעגל

מכיוון שביצירות שלי יש רק אור אחד בלבד, כך שקל מאוד להלחם. הבעיה העיקרית היא בהתחלה, אני מלחמת שני אור, אבל לא כיסיתי את חלק החשיפה באופן מיידי. אז כאשר שני החוטים נפרדים נוגעים זה בזה. זה קצר.

שלב 2: שלב 2: כתוב את הקוד

p.p1 {שוליים: 0.0px 0.0px 0.0px 0.0px; קו גובה: 15.0 פיקסלים; גופן: 12.0px Times; צבע: #000000; צבע רקע: #ffffff}

p.p2 {שוליים: 0.0px 0.0px 0.0px 0.0px; קו גובה: 15.0 פיקסלים; גופן: 12.0px Times; צבע: #000000; צבע-רקע: #ffffff; min-height: 14.0px} span.s1 {font-kerning: none}

שלב 2: כתוב את הקוד

/*********************************************************************

זוהי דוגמה למודולים מבוססי nRF52 שלנו של Bluefruit LE

קח אחד היום בחנות adafruit!

Adafruit משקיעה זמן ומשאבים במתן קוד קוד פתוח זה, אנא תמכו ב- Adafruit ובחומרת קוד פתוח על ידי רכישה

מוצרים של Adafruit!

רישיון MIT, בדוק את LICENSE למידע נוסף

כל הטקסט למעלה, ומסך ההתזה למטה חייבים להיכלל

כל חלוקה מחדש

*********************************************************************

/ סקיצה זו מיועדת לשימוש עם הפקד NeoPixel

// משטח ביישום הנייד Bluefruit LE Connect של Adafruit.

/

/ - הידור והבהב את המערכון הזה לנוצה nRF52

// - פתח את אפליקציית Bluefruit LE Connect

// - עבור לכלי השירות NeoPixel

// - לחץ על כפתור 'התחבר' כדי ליצור חיבור ו-

// שלח את נתוני המטא לגבי פריסת הפיקסלים

// - השתמש בכלי השירות NeoPixel כדי לעדכן את הפיקסלים במכשיר שלך

/* הערה: מערכון זה דרש לפחות גירסה 1.1.0 של Adafruit_Neopixel !!! */

#לִכלוֹל

#לִכלוֹל

#לִכלוֹל

#הגדר NEOPIXEL_VERSION_STRING "Neopixel v2.0"

#define PIN 16 / * PIN המשמש להנעת NeoPixels * /

#הגדירו מרכיבים 4

uint8_t *pixelBuffer = NULL;

uint8_t width = 0;

uint8_t גובה = 0;

uint8_t צעד;

uint8_t componentsValue;

bool הוא 400Hz;

uint8_t רכיבים = 3; // רק 3 ו -4 הם ערכים תקפים

Adafruit_NeoPixel neopixel = Adafruit_NeoPixel ();

// שירות BLE

BLEDfu bledfu;

BLEDis bledis;

BLEUart bleuart;

הגדרת חלל ()

{

Serial.begin (115200);

בעוד (! סדרתי) עיכוב (10); // עבור nrf52840 עם USB מקורי

Serial.println ("בדיקת ניאפיקסל של אדפרוט Bluefruit");

Serial.println ("--------------------------------");

Serial.println ();

Serial.println ("אנא התחבר באמצעות יישום Bluefruit Connect LE");

// Config Neopixels

neopixel.begin ();

// ראשוני Bluefruit

Bluefruit.begin ();

Bluefruit.setTxPower (4); // בדוק את הערכים הנתמכים ב- bluefruit.h

Bluefruit.setName ("Bluefruit52");

Bluefruit. Periph.setConnectCallback (connect_callback);

// כדי להיות עקבי יש להוסיף OTA DFU תחילה אם הוא קיים

bledfu.begin ();

// הגדר והפעל את שירות פרטי המכשיר

bledis.setManufacturer ("תעשיות אדפרוט");

bledis.setModel ("נוצה Bluefruit52");

bledis.begin ();

// הגדר והתחל שירות BLE UART

bleuart.begin ();

// הגדר והתחל לפרסם

startAdv ();

}

void startAdv (void)

{

// חבילת פרסום

Bluefruit. Advertising.addFlags (BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);

Bluefruit. Advertising.addTxPower ();

// כלול uuid bleuart של 128 סיביות

Bluefruit. Advertising.addService (bleuart);

// חבילת תגובת סריקה משנית (אופציונלי)

// מכיוון שאין מקום ל'שם 'בחבילת הפרסום

Bluefruit. ScanResponse.addName ();

/* התחל לפרסם

* - אפשר פרסום אוטומטי אם הוא מנותק

* - מרווח: מצב מהיר = 20 ms, מצב איטי = 152.5 ms

* - הזמן הקצוב למצב מהיר הוא 30 שניות

* - התחל (פסק זמן) עם פסק זמן = 0 יפרסם לנצח (עד לחיבור)

*

* למרווח פרסום מומלץ

*

*/

Bluefruit. Advertising.restartOnDisconnect (נכון);

Bluefruit. Advertising.setInterval (32, 244); // ביחידה של 0.625 אלפיות השנייה

Bluefruit. Advertising.setFastTimeout (30); // מספר שניות במצב מהיר

Bluefruit. Advertising.start (0); // 0 = אל תפסיק לפרסם לאחר n שניות

}

void connect_callback (uint16_t conn_handle)

{

// קבל את ההפניה לחיבור הנוכחי

חיבור BLEConnection* = Bluefruit. Connection (conn_handle);

char central_name [32] = {0};

connection-> getPeerName (central_name, sizeof (central_name));

Serial.print ("מחובר ל-");

Serial.println (שם מרכזי);

Serial.println ("אנא בחר בכרטיסייה 'Neopixels', לחץ על 'התחבר' ותהנה");

}

לולאת חלל ()

{

// הד קיבל נתונים

אם (Bluefruit.connected () && bleuart.notifyEnabled ())

{

int command = bleuart.read ();

switch (פקודה) {

מקרה 'V': {// קבל גרסה

commandVersion ();

לשבור;

}

מקרה 'S': {// הגדרת מידות, רכיבים, צעד …

commandSetup ();

לשבור;

}

מקרה 'C': {// ברור עם צבע

commandClearColor ();

לשבור;

}

מקרה 'B': {// הגדר בהירות

commandSetBrightness ();

לשבור;

}

מקרה 'P': {// הגדר פיקסל

commandSetPixel ();

לשבור;

}

מקרה 'אני': {// קבל תמונה חדשה

commandImage ();

לשבור;

}

}

}

}

החלפת חלל בופרים ()

{

uint8_t *base_addr = pixelBuffer;

int pixelIndex = 0;

עבור (int j = 0; j <height; j ++)

{

עבור (int i = 0; i <width; i ++) {

אם (רכיבים == 3) {

neopixel.setPixelColor (pixelIndex, neopixel. Color (*base_addr, *(base_addr+1), *(base_addr+2)));

}

אחר {

neopixel.setPixelColor (pixelIndex, neopixel. Color (*base_addr, *(base_addr+1), *(base_addr+2), *(base_addr+3))));

}

base_addr+= רכיבים;

pixelIndex ++;

}

pixelIndex += stride - רוחב; // העבר את pixelIndex לשורה הבאה (קח בחשבון את הצעד)

}

neopixel.show ();

}

void commandVersion () {

Serial.println (F ("פקודה: בדיקת גרסה"));

sendResponse (NEOPIXEL_VERSION_STRING);

}

void commandSetup () {

Serial.println (F ("פקודה: התקנה"));

width = bleuart.read ();

גובה = bleuart.read ();

stride = bleuart.read ();

ComponentsValue = bleuart.read ();

is400Hz = bleuart.read ();

neoPixelType pixelType;

pixelType = componentsValue + (is400Hz? NEO_KHZ400: NEO_KHZ800);

רכיבים = (ComponentsValue == NEO_RGB || ComponentsValue == NEO_RBG || ComponentsValue == NEO_GRB || ComponentsValue == NEO_GBR || ComponentsValue == NEO_BRG || ComponentsValue == NEO_BGR)? 3: 4;

Serial.printf ("\ tsize: %dx %d / n", רוחב, גובה);

Serial.printf ("\ tstride: %d / n", סטרייד);

Serial.printf ("\ tpixelType %d / n", pixelType);

Serial.printf ("\ tcomponents: %d / n", רכיבים);

if (pixelBuffer! = NULL) {

מחק pixelBuffer;

}

uint32_t גודל = רוחב*גובה;

pixelBuffer = uint8_t חדש [גודל*רכיבים];

neopixel.updateLength (גודל);

neopixel.updateType (pixelType);

neopixel.setPin (PIN);

// בוצע

sendResponse ("אישור");

}

void commandSetBrightness () {

Serial.println (F ("Command: SetBrightness"));

// קרא ערך

בהירות uint8_t = bleuart.read ();

// הגדר בהירות

neopixel.setBrightness (בהירות);

// רענן פיקסלים

swapBuffers ();

// בוצע

sendResponse ("אישור");

}

void commandClearColor () {

Serial.println (F ("פקודה: ClearColor"));

// קראו צבע

uint8_t color [MAXCOMPONENTS];

עבור (int j = 0; j <רכיבים;) {

if (bleuart.available ()) {

צבע [j] = bleuart.read ();

j ++;

}

}

// הגדר את כל הנורות לצבע

גודל int = רוחב * גובה;

uint8_t *base_addr = pixelBuffer;

עבור (int i = 0; i <size; i ++) {

עבור (int j = 0; j <רכיבים; j ++) {

*base_addr = צבע [j];

base_addr ++;

}

}

// החלף מאגרים

Serial.println (F ("ClearColor הושלם"));

swapBuffers ();

אם (רכיבים == 3) {

Serial.printf ("\ tclear (%d, %d, %d) n", צבע [0], צבע [1], צבע [2]);

}

אחר {

Serial.printf ("\ tclear (%d, %d, %d, %d) n", צבע [0], צבע [1], צבע [2], צבע [3]);

}

// בוצע

sendResponse ("אישור");

}

void commandSetPixel () {

Serial.println (F ("Command: SetPixel"));

// קרא עמדה

uint8_t x = bleuart.read ();

uint8_t y = bleuart.read ();

// קראו צבעים

uint32_t pixelOffset = y*רוחב+x;

uint32_t pixelDataOffset = pixelOffset*רכיבים;

uint8_t *base_addr = pixelBuffer+pixelDataOffset;

for (int j = 0; j <רכיבים;) {

if (bleuart.available ()) {

*base_addr = bleuart.read ();

base_addr ++;

j ++;

}

}

// קבע צבעים

uint32_t neopixelIndex = y*stride+x;

uint8_t *pixelBufferPointer = pixelBuffer + pixelDataOffset;

צבע uint32_t;

אם (רכיבים == 3) {

color = neopixel. Color (*pixelBufferPointer, *(pixelBufferPointer+1), *(pixelBufferPointer+2));

Serial.printf ("\ tcolor (%d, %d, %d) n", *pixelBufferPointer, *(pixelBufferPointer+1), *(pixelBufferPointer+2));

}

אחר {

color = neopixel. Color (*pixelBufferPointer, *(pixelBufferPointer+1), *(pixelBufferPointer+2), *(pixelBufferPointer+3));

Serial.printf ("\ tcolor (%d, %d, %d, %d) n", *pixelBufferPointer, *(pixelBufferPointer+1), *(pixelBufferPointer+2), *(pixelBufferPointer+3));

}

neopixel.setPixelColor (neopixelIndex, צבע);

neopixel.show ();

// בוצע

sendResponse ("אישור");

}

void commandImage () {

Serial.printf ("פקודה: תמונה %dx %d, %d, %d / n", רוחב, גובה, רכיבים, צעד);

// קבל מאגר פיקסלים חדש

גודל int = רוחב * גובה;

uint8_t *base_addr = pixelBuffer;

עבור (int i = 0; i <size; i ++) {

עבור (int j = 0; j <רכיבים;) {

if (bleuart.available ()) {

*base_addr = bleuart.read ();

base_addr ++;

j ++;

}

}

/*

אם (רכיבים == 3) {

uint32_t index = i*רכיבים;

Serial.printf ("\ tp %d (%d, %d, %d) n", i, pixelBuffer [index], pixelBuffer [index+1], pixelBuffer [index+2]);

}

*/

}

// החלף מאגרים

Serial.println (F ("התמונה התקבלה"));

swapBuffers ();

// בוצע

sendResponse ("אישור");

}

void sendResponse (char const *response) {

Serial.printf ("שלח תגובה: %s / n", תגובה);

bleuart.write (תגובה, strlen (תגובה)*sizeof (char));

}

שלב 3: שלב 3: רכישת אהיל

שלב 3: רכישת אהיל
שלב 3: רכישת אהיל
שלב 3: רכישת אהיל
שלב 3: רכישת אהיל

שלב 4: שלב 4: משוך הכל ביחד

מוּמלָץ: