سلام.
يه سوال دارم كه تا حالا بهش برنخورده بودم لطفاً اساتيد راهنماييم كنن.
چطوري نتيجه يه محاسبه كه يه عدد اعشاري هست رو روي lcd كاراكتري و همچنين n96 نشون ميديم؟!!!
دستور تبديلش چيه؟
اينم بگم sprintf جواب نميده.
ممنون
نمایش نسخه قابل چاپ
سلام.
يه سوال دارم كه تا حالا بهش برنخورده بودم لطفاً اساتيد راهنماييم كنن.
چطوري نتيجه يه محاسبه كه يه عدد اعشاري هست رو روي lcd كاراكتري و همچنين n96 نشون ميديم؟!!!
دستور تبديلش چيه؟
اينم بگم sprintf جواب نميده.
ممنون
سلام
من قبلا از این روش استفاده کرده بودم ولی یادم نیست برای چی بود !!!
با تقسیم و ضرب کردن مقدار صحیح و اعشار رو جدا کن و جداگانه نمایش بده
دات بینشون رو هم جداگانه میتونی قرار بدی
من که n بار استفاده کردم جواب داده.نقل قول:
نوشته اصلی توسط mostafa-plc [Dear Guest/Member you can't see link before replyclick here to register]
سلام.
حسين جان آره منم همين راه به نظرم رسيد كه از Mod استفاده كنم و... ولي خواستم مطمئن شم روش ساده تري تري داره يا نه...
علي آقا دستور من اينه:
کد:sprintf(result,"%f",floatnum );
ولي روي lcd n96 به جاي عدد مربع هاي سفيد نيمه خالي نشون ميده.کد:tftlcd_putsf(result,RED,WHITE,0);
این قاعدتا باید جواب بده منم باهاش مشکلی نداشتم - احتمالا برر می گرده به تنظیمات کامپایلر - چرا کمه این توابع به صورت کامل حافظه زیادی میخواد کامپایلر به صورت پیشفرض این توابع رو مینیمم میکنه!
توی iar این گذینه رو دیدم ولی تو کیل این گذینه رو نمی بینم ! البته منم تا حالا این مشکل رو نداشتم
مصطفی من همین الان این کد رو روی lcdn96 خودم در کیل با LPc1768 تست کردم عدد رو با اعشار بدون مشکل نمایش داد.
همون طور که اقای مزارعی گفتن به نظر من هم به تنظیمات کامپایلر بر می گرده که البته برای من روی حالت پیشفرض کیل قرار داره.
کد:char buff[20];
float a=3.234;
sprintf(buff, "%f", a);
tftlcd_init();
tftlcd_gotoxy(1,2);
tftlcd_puts(buff, BLACK, WHITE, 1);
علي آقا ممنون مشكلم حل شد:wink:
اشتباه من اين بود كه متغير result م رو char عادي تعريف نكرده بودم:baad: و به صورت string يعني
تعريف كرده بودم .کد:char *result
حالا يه مشكل جديد!!!!!
اين همه eror چيه؟!! :
اصلاً معني خاصيم ندارن ولي موقع كامپايل اينا رو گير ميده!کد:compiling LCD n96.c...
LCD n96.c(386): warning: #223-D: function "sprintf" declared implicitly
LCD n96.c(656): warning: #223-D: function "sprintf" declared implicitly
LCD n96.c(924): warning: #223-D: function "sprintf" declared implicitly
LCD n96.c(1192): warning: #223-D: function "sprintf" declared implicitly
linking...
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(lludiv10.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(strcmp.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$fnorm2(fnorm2_noclz.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$funder(funder.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .constdata(bigflt0.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(_printf_fp_infnan.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dleqf(dleqf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$frleqf(frleqf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dcmpinfnan(dcmpin.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(__printf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$fleqf(fleqf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$retnan(retnan.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section CL$$btod_d2e_norm_op1(btod.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$f2d(f2d.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dcmpinfnan(fcmpin.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(sys_stackheap_outer.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dflt(dflt_noclz.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section CL$$btod_d2e_denorm_low(btod.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section locale$$code(lc_numeric_c.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$trapveneer(trapv.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section CL$$btod_d2e(btod.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section CL$$btod_emul(btod.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section CL$$btod_ediv(btod.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section i.__ARM_fpclassify(fpclassify.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(rtudiv10.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(noretval__2sprintf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .ARM.Collect$$rtentry$$0000000D(rtentry2.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(sam7.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text_udiv(aeabi_sdiv.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section locale$$data(lc_numeric_c.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(sys_exit.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dcheck(dcheck.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$dcheck1(dcheck1.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(rt_locale_intlibspace.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$fcheck(fcheck.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$fcheck1(fcheck1.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(libspace.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(exit.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .ARM.Collect$$libinit$$0000002F(libinit2.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(_sputc.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .ARM.Collect$$_printf_percent$$00000003(_printf_f.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$ieeestatus(istatus.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(heapauxi.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .ARM.Collect$$libshutdown$$0000000F(libshutdown2.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$printf1(printf1.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section x$fpl$fpinit(fpinit.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .ARM.Collect$$rtexit$$00000003(rtexit2.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section .text(use_no_semi.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section i.__ARM_common_call_via_r2(__printf.o).
LCD n96.axf: Error: L6406W: No space in execution regions with .ANY selector matching Section i.__ARM_common_call_via_r1(__printf.o).
LCD n96.axf: Error: L6407W: Sections of aggregate size 0xbe0 bytes could not fit into .ANY selector(s).
Target not created
الان فهميدم كه اين ارور ها رو واس حجم برنامم ميگيره و ربطي به دستورات sprintf و اينا نداره! بايد حجم رو كم كنم.
ممنون از همفكريتون دوستان.
الان جای یه سوال مطرحه که چرا دوستان فکر میکنن که اشاره گر به متغیر کارکتری رو به معنای یه String معنی میکنن ؟! من تو کد های نوشته شده توسط آقای تروشه این اشتباه رو به وفور دیدم !
این تیکه را میشه بازتر کنید درست و غلطشو بگید .من نگرفتم چی درسته چی غلط !نقل قول:
نقل قول:
agape جان تا اونجايي كه من ميدونم و البته تو كتاب آقاي جعفر نژاد هم گفته، در c نوع متغير string نداريم و اگه نياز داشته باشيم بايد يه pointer با نوع char ايجاد كنيم و string ما از اولين خونه شروع به پر شدن ميكنه و نوشته ميشه، اينجا كمي بحث شده:
[Dear Guest/Member you can't see link before replyclick here to register]
البته واس منم سواله دقيقاً چرا اين راه حلشه ولي خب استفاده ميشه به هر حال....
string یه سری کارکتر (آرایه) از نوع char هست که به کارکتر نول ختم شده باشه. انتهای string از روی همین نول مشخص میشه.
اسم آرایه هم به تنهایی اشاره گری به ابتدای آرایه هست و نیازی نیست از اول یه اشاره گر به المان اولش تعریف بشه.
اما این درست نیست که یه اشاره گره خالی فقط تعریف کنیم! باید سایز string مشخص باشه!!!
البته این تعریفی هست که در C بهش توی کتاب ها اشاره شده، من نمی دونم این آیا با متغیر نوع string که در c++ وجود داره تفاوت جزئی یا کلی داره یا نه!
سلام.دوستان من میخام دستور ی ال سی دی رو به ال سی دی n96تغییر بدم.کار خودم نیست اما نیاز پیدا کردم.دستورش اینهالانبایدطوری تبدیلش کنم که تویn96نشون داده بشه.
sprintf(as,"%c%c%c%c%c%c-",GPS_Data[y_Save-45],GPS_Data[y_Save-44],GPS_Data[y_Save-43],GPS_Data[y_Save-42],GPS_Data[y_Save-41],GPS_Data[y_Save-40]);
lcd_puts(as,YELLOW,0,BLACK);
میشه لطفا راهنمایی کنید؟
ممنون