Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI SDFileSystem
Revision 2:263046c359da, committed 2019-08-16
- Comitter:
- malithjkd
- Date:
- Fri Aug 16 07:59:10 2019 +0000
- Parent:
- 1:e4d7342be507
- Commit message:
- SDcard write encoder value
Changed in this revision
| QEI.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Fri Aug 16 07:59:10 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
--- a/main.cpp Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp Fri Aug 16 07:59:10 2019 +0000
@@ -1,19 +1,49 @@
#include "mbed.h"
#include "SDFileSystem.h"
-
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
-
-int main() {
- printf("Hello World!\n");
-
+#include "QEI.h"
+
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board p5 - mosi, p6-miso, p7 - sck, p8 - cs
+Serial pc (USBTX,USBRX);
+QEI wheel (p29, p30, NC, 2000, QEI::X4_ENCODING); //for encoder
+
+
+void sd_card_read_test(void);
+void file_write_int(int input);
+
+int i= 2;
+
+int main()
+{
+ sd_card_read_test();
+ while(1){
+ //pc.printf("Pulses is: %i\r\n", wheel.getPulses());
+ file_write_int(wheel.getPulses());
+ }
+
+}
+
+void sd_card_read_test(void)
+{
+ pc.printf("SD card test");
mkdir("/sd/mydir", 0777);
-
FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
- if(fp == NULL) {
+ if(fp == NULL)
+ {
error("Could not open file for write\n");
}
- fprintf(fp, "Hello fun SD Card World!");
- fclose(fp);
-
- printf("Goodbye World!\n");
+ fprintf(fp, "Test QUI\r\n");
+ fclose(fp);
+ pc.printf("[ok]\r\n");
}
+
+void file_write_int(int input)
+{
+ FILE *fp = fopen("/sd/mydir/sdtest.txt", "a");
+ if(fp == NULL)
+ {
+ error("Could not open file for write\n");
+ }
+ fprintf(fp,"%d\r\n",input);
+ fclose(fp);
+}
+