——Gan Fforwm Datblygwyr DWIN
Yn y rhifyn hwn, byddwn yn cyflwyno'r achos ffynhonnell agored arobryn o Fforwm Datblygwyr DWIN: System Rheoli Bwyd Cath Deallus.Defnyddiodd peirianwyr sgrin smart DWIN i fonitro'r tymheredd, y lleithder a'r swm sy'n weddill o fwyd cath, ac i arbed cofnodion bwyta bwyd y gath.Fe wnaethant hefyd ddylunio set o UI arddull peintio inc yn unigryw, yn ogystal ag effaith clicio inc pan fydd bys yn ei gyffwrdd, i wella'r canfyddiad gweledol o adborth cyffwrdd.
Cyflwyniad:
Deunydd llun 1.UI
Mae sgrin smart DWIN yn cwblhau datblygiad UI yn seiliedig ar luniau, mae angen paratoi sain a deunyddiau eraill ymlaen llaw yn ôl cynnwys arddangos y sgrin.
Datblygiad 2.Interface
Mae meddalwedd DGUS yn adfer yr effaith UI trwy droshaeniad haenau, yn cyfuno'r deunyddiau parod yn ddarlun cyflawn yn y meddalwedd DGUS, ac yn gosod y swyddogaethau arddangos a chyffwrdd.
3. Gweithredu effeithiau cliciwch ac effeithiau sain
Mae'r sefyllfa gyffwrdd yn cael ei sicrhau trwy'r rhaglen 51, mae'r effaith wasgu yn dilyn symudiad y bys, a chyflawnir effaith sain allweddol y cyfeiliant hefyd.
(1) Canfod cod lleoliad cyffwrdd a chwarae sain:
gwagle TouchDetect()
{
u16 Va[3] = 0;
u8 i = 0;
ar gyfer(i = 0; i < 3; i++)
{
Va[i] = Darllen_Dgus(0x0016 + i);
os(Va[0] == 0x5A01)
{
}
arall
{
torri;
}
}
os(i!= 0) // Cliciwch yn gyntaf i fynd i mewn
{
u16 chwarae[2] = {0x0001, 0x4000};
touchAnimationFlag = 1;
touchAnimationCnt = 0;
touchPosX = Va[1];
touchPosY = Va[2];
write_dgus_vp(0x00A0, chwarae, 2);
}
}
(2) Mae'r cod ar gyfer arddangos effaith gyffwrdd fel a ganlyn:
TouchStart() gwag
{
os(touchAnimationFlag == 1)
{
os(touchAnimationCnt == 0)
{
Write_Dgus(0x5011, touchPosX - 100);
Write_Dgus(0x5012, touchPosY - 100);
}
Write_Dgus(0x5000, touchAnimationCnt);
cyffwrddAnimationCnt++;
os(touchAnimationCnt == 6)
{
touchAnimationFlag = 0;
Write_Dgus(0x5011, 1024);
Write_Dgus(0x5012, 600);
}
}
}
4. Y cam nesaf yw gosod y paramedrau cyfatebol drwy'r sgrin, ac yna trosglwyddo'r data i'r rheolydd bwyd cathod trwy ESP32 i wireddu swyddogaeth bwydo awtomatig bwyd cathod.Mae'r cod penodol fel a ganlyn:
//Cael statws botwm
gwacter get_key_status()
{
int i = 0;
//u16 Va=Read_Dgus(addr);
u16 Va=Darllen_Dgus(0x1000);
os(Va!= 0x0000)
{
//Studalen tatus
os(Va == 0x0103) // Rhowch nifer y g
{
u16 switchpage[2] = {0x5A01, 19};
setNum = lleGramNum;
backPage = 1;// Dychwelyd i'r dudalen statws
Write_Dgus(0x4000 + 0, setNum % 10);
Write_Dgus(0x4000 + 2, setNum / 10 % 10);
Write_Dgus(0x4000 + 4, setNum / 100 % 10);
Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
write_dgus_vp(0x0084, switchpage, 2);
}
arall os(Va == 0x0102)
{
OneSendData3(placeGramNum);//Llebwyd cathunwaith
}
arall os(Va == 0x0101) // Gosod tudalen
{
u16 switchpage[2] = {0x5A01, 3};
ar gyfer(i = 0; i < 6; i++)
{
os(i == 0)
{
Write_Dgus(0x3070 + i * 0x10 + 0, currentTime[i] % 10);
Write_Dgus(0x3070 + i * 0x10 + 2, Amser cyfredol[i] / 10 % 10);
Write_Dgus(0x3070 + i * 0x10 + 4, Amser cyfredol[i] / 100 % 10);
Write_Dgus(0x3070 + i * 0x10 + 6, Amser cyfredol[i] / 1000 % 10);
}
arall
{
Write_Dgus(0x3070 + i * 0x10 + 0, currentTime[i] % 10);
Write_Dgus(0x3070 + i * 0x10 + 2, Amser cyfredol[i] / 10 % 10);
}
}
write_dgus_vp(0x0084, switchpage, 2);// Rhowch y dudalen gosodiadau
}
arall os(Va == 0x0100) //Rtudalen record
{
u16 switchpage[2] = {0x5A01, 2};
ar gyfer(i = 0; i < 6; i++)
{
os(i == 0)
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[0][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[0][i] / 10 % 10);
Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[0][i] / 100 % 10);
Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[0][i] / 1000 % 10);
}
arall
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[0][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[0][i] / 10 % 10);
}
}
write_dgus_vp(0x0084, switchpage, 2);//Rhowch dudalen cofnod
}
//Rtudalen record
arall os(Va == 0x0201) // Cofnodwch y dudalen flaenorol
{
os(lookEatCnt > 0)
{
edrychEatCnt--;
ar gyfer(i = 0; i < 6; i++)
{
os(i == 0)
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[lookEatCnt][i] / 100 % 10);
Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[lookEatCnt][i] / 1000 % 10);
}
arall
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
}
}
}
}
arall os(Va == 0x0202) // Cofnodwch y dudalen nesaf
{
if(lookEatCnt < eatCnt - 1)
{
lookEatCnt++;
ar gyfer(i = 0; i < 6; i++)
{
os(i == 0)
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
Write_Dgus(0x2000 + i * 0x10 + 4, eatFeedList[lookEatCnt][i] / 100 % 10);
Write_Dgus(0x2000 + i * 0x10 + 6, eatFeedList[lookEatCnt][i] / 1000 % 10);
}
arall
{
Write_Dgus(0x2000 + i * 0x10 + 0, eatFeedList[lookEatCnt][i] % 10);
Write_Dgus(0x2000 + i * 0x10 + 2, eatFeedList[lookEatCnt][i] / 10 % 10);
}
}
}
}
//tudalen gosod
arall os(Va == 0x0302)
{
os(timeMode == 1)
{
timeMode = 0;
Write_Dgus(0x3A12, 139);
}
}
arall os(Va == 0x0303)
{
os(timeMode == 0)
{
timeMode = 1;
Write_Dgus(0x3A12, 242);
}
}
arall os(Va>= 0x0304 && Va <= 0x0309)
{
u16 switchpage[2] = {0x5A01, 19};
backPage = 3;
cefnNum = Va;
setNum = timrIntervalHour[Va - 0x0304];
Write_Dgus(0x4000 + 0, setNum % 10);
Write_Dgus(0x4000 + 2, setNum / 10 % 10);
Write_Dgus(0x4000 + 4, setNum / 100 % 10);
Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
write_dgus_vp(0x0084, switchpage, 2);
}
arall os(Va>= 0x030A && Va <= 0x030F)
{
u16 switchpage[2] = {0x5A01, 19};
backPage = 3;
cefnNum = Va;
setNum = Amser presennol[Va - 0x030A];
Write_Dgus(0x4000 + 0, setNum % 10);
Write_Dgus(0x4000 + 2, setNum / 10 % 10);
Write_Dgus(0x4000 + 4, setNum / 100 % 10);
Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
write_dgus_vp(0x0084, switchpage, 2);
}
//Atudalen data addasu
arall os(Va == 0x0400) //Cadarnhau
{
u16 switchpage[2] = {0x5A01, 0x0000};
switchpage[1] = tudalen gefn;
if(backPage == 1) // Dychwelyd i'r dudalen statws
{
placeGramNum = setNum;
Write_Dgus(0x1140 + 0, placeGramNum % 10);
Write_Dgus(0x1140 + 2, placeGramNum / 10 % 10);
}
arall os(Tudalen gefn == 3)
{
os(backNum>= 0x0304 && backNum <= 0x0309)
{
u16 dewis = 0;
dewiswch = (backNum - 0x0304) * 0x10;
timrIntervalHour[backNum - 0x0304] = setNum;
Write_Dgus(0x3010 + dewis + 0, setNum % 10);
Write_Dgus(0x3010 + dewis + 2, setNum / 10 % 10);
}
arall os(backNum>= 0x030A && backNum <= 0x030F)
{
u16 dewis = 0;
dewiswch = (backNum - 0x0304) * 0x10;
currentTime[backNum - 0x030A] = setNum;
os(backNum == 0x030A)
{
Write_Dgus(0x3010 + dewis + 0, setNum % 10);
Write_Dgus(0x3010 + dewis + 2, setNum / 10 % 10);
Write_Dgus(0x3010 + dewis + 4, setNum / 100 % 10);
Write_Dgus(0x3010 + dewis + 6, setNum / 1000 % 10);
}
arall
{
Write_Dgus(0x3010 + dewis + 0, setNum % 10);
Write_Dgus(0x3010 + dewis + 2, setNum / 10 % 10);
}
}
}
write_dgus_vp(0x0084, switchpage, 2);
}
arall os(Va == 0x0401) //Yn ol
{
u16 switchpage[2] = {0x5A01, 0x0000};
switchpage[1] = tudalen gefn;
write_dgus_vp(0x0084, switchpage, 2);
}
arall os(Va == 0x0402) // Cynnydd rhifiadol
{
setNum++;
Write_Dgus(0x4000 + 0, setNum % 10);
Write_Dgus(0x4000 + 2, setNum / 10 % 10);
Write_Dgus(0x4000 + 4, setNum / 100 % 10);
Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
}
arall os(Va == 0x0403) // Gostyngiad rhifiadol
{
os(setNum> 0)
setNum--;
Write_Dgus(0x4000 + 0, setNum % 10);
Write_Dgus(0x4000 + 2, setNum / 10 % 10);
Write_Dgus(0x4000 + 4, setNum / 100 % 10);
Write_Dgus(0x4000 + 6, setNum / 1000 % 10);
}
Write_Dgus(0x1000, 0);
}
}
Amser post: Medi-19-2023