Change in osmocom-bb[master]: Adjusted coding style.

2020-08-06 Thread laforge
laforge has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19489 )

Change subject: Adjusted coding style.
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19489
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I9b5250579290b6eb1e33d446e9fc7d2c082c4002
Gerrit-Change-Number: 19489
Gerrit-PatchSet: 1
Gerrit-Owner: roox 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmocom-bb[master]: Adjusted coding style.

2020-08-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19489 )

Change subject: Adjusted coding style.
..


Patch Set 1:

I think this should be part of the initial commit.  If its easier, I think the 
patch series could be restructured as follows:
* one correctly formatted for each logical functional change to the existing 
code / infrastructure (additional FB function, power button handling, ...)
* one squashed commit adding the snake program, it's incremental fixes and 
coding style correction


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19489
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I9b5250579290b6eb1e33d446e9fc7d2c082c4002
Gerrit-Change-Number: 19489
Gerrit-PatchSet: 1
Gerrit-Owner: roox 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-Comment-Date: Sun, 02 Aug 2020 07:11:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmocom-bb[master]: Adjusted coding style.

2020-08-01 Thread roox
roox has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19489 )


Change subject: Adjusted coding style.
..

Adjusted coding style.

Change-Id: I9b5250579290b6eb1e33d446e9fc7d2c082c4002
---
M src/target/firmware/apps/snake_game/main.c
1 file changed, 191 insertions(+), 105 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/89/19489/1

diff --git a/src/target/firmware/apps/snake_game/main.c 
b/src/target/firmware/apps/snake_game/main.c
index 98a5b34..d9748f7 100644
--- a/src/target/firmware/apps/snake_game/main.c
+++ b/src/target/firmware/apps/snake_game/main.c
@@ -20,7 +20,6 @@
  *
  */

-
 #include 
 #include 

@@ -50,11 +49,14 @@

 unsigned long next = 1;
 /* This is not a good random number generator ... */
-int rand(void) {
+int rand(void)
+{
next = next * 110351 + 12;
return (unsigned int)(next & 0x7fff);
 }
-void srand(unsigned int seed) {
+
+void srand(unsigned int seed)
+{
next = seed;
 }

@@ -66,7 +68,7 @@
 #define SBODY 20
 /* The numbers above 20 are the distance to the head.
  * 21 is direly behind the head.
-*/
+ */
 #define STDLEN 3
 #define HEIGHT 7
 #define WIDTH 16
@@ -81,19 +83,22 @@

 uint8_t field[WIDTH][HEIGHT];
 int16_t score = 0, lenght = 0;
-enum errors { ALLRIGHT, SNAKE_COL,  } err;
+enum errors { ALLRIGHT, SNAKE_COL } err;

 void printField();
 void setItem(int, int, int);
 void movepos(char);
 void increaseBodyAge();
-void setFood() {
+void setFood()
+{
int x, y, c;
-   for (c = 0; c < 10;c++) {
-   x = rand() % (WIDTH -1);
-   y = rand() % (HEIGHT -1);
-   if (DEBUG > 0) printf("Next %u\n", next);
-   if (DEBUG > 0) printf("Rand (%d|%d)\n", x, y);
+   for (c = 0; c < 10; c++) {
+   x = rand() % (WIDTH - 1);
+   y = rand() % (HEIGHT - 1);
+#if DEBUG > 0
+   printf("Next %u\n", next);
+   printf("Rand (%d|%d)\n", x, y);
+#endif
if (field[x][y] == BLANK) {
field[x][y] = FOOD;
return;
@@ -103,7 +108,10 @@
for (y = 0; y < HEIGHT; y++) {
if (field[x][y] == BLANK) {
field[x][y] = FOOD;
-   if (DEBUG > 0) printf("Set without rand (%d|%d) 
%d\n", x, y, c);
+#if DEBUG > 0
+   printf("Set without rand (%d|%d) %d\n", x, y,
+  c);
+#endif
return;
}
}
@@ -113,127 +121,172 @@
 static void print_snake_str(char *text, int16_t x, int16_t y)
 {
x = 6 * x;
-   y = 8 * (y+1) -3;
-   if (DEBUG > 1) printf("Put string %s to (%d|%d)\n", text, x, y);
+   y = 8 * (y + 1) - 3;
+#if DEBUG > 1
+   printf("Put string %s to (%d|%d)\n", text, x, y);
+#endif
fb_gotoxy(x, y);
fb_putstr(text, framebuffer->width);
 }

-
 char Move;
-void movepos(char move) {
+void movepos(char move)
+{
Move = move;
setItem(pos.x, pos.y, SBODY);
switch (move) {
-   case 'h': pos.x--;break;
-   case 'j': pos.y++;break;
-   case 'k': pos.y--;break;
-   case 'l': pos.x++;break;
+   case 'h': pos.x--; break;
+   case 'j': pos.y++; break;
+   case 'k': pos.y--; break;
+   case 'l': pos.x++; break;
}
switch (move) {
-   case 'j': case 'k':
-   if (pos.y == -1) pos.y = HEIGHT -1;
-   else if (pos.y == HEIGHT) pos.y = 0;
-   increaseBodyAge();
-   break;
-   case 'l': case 'h':
-   if (pos.x == -1) pos.x = WIDTH -1;
-   else if (pos.x == WIDTH) pos.x = 0;
-   increaseBodyAge();
-   break;
+   case 'j':
+   case 'k':
+   if (pos.y == -1)
+   pos.y = HEIGHT - 1;
+   else if (pos.y == HEIGHT)
+   pos.y = 0;
+   increaseBodyAge();
+   break;
+   case 'l':
+   case 'h':
+   if (pos.x == -1)
+   pos.x = WIDTH - 1;
+   else if (pos.x == WIDTH)
+   pos.x = 0;
+   increaseBodyAge();
+   break;
}
setItem(pos.x, pos.y, HEAD);
printField();
 }
-void movepos_timer_cb(void *p) {
-   struct osmo_timer_list *tmr = (struct osmo_timer_list*)p;
-   if (DEBUG > 0) printf("Auto move %c\n", Move);
+
+void movepos_timer_cb(void *p)
+{
+   struct osmo_timer_list *tmr = (struct osmo_timer_list *)p;
+#if DEBUG > 0
+   printf("Auto move %c\n", Move);
+#endif
movepos(Move);

osmo_timer_schedule(tmr, WAIT_TIME_AUTOMOVE);
 }
+
 static struct