Skip to content

Commit 04098a3

Browse files
committed
minor cleanup
1 parent 8464088 commit 04098a3

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/modules/out_5a_75e.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int init(void) {
124124
struct ifreq if_idx;
125125

126126
/* Open RAW socket to send on */
127-
if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1)
127+
if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) < 0)
128128
{
129129
perror("socket");
130130
}
@@ -183,6 +183,7 @@ int clear(int _modno)
183183

184184
int render(void)
185185
{
186+
// Limit frame rate. In this configuration, the matrix is only stable up to ~70fps
186187
static oscore_time last = 0;
187188
oscore_time now = udate();
188189
oscore_time elapsed = now - last;
@@ -193,18 +194,7 @@ int render(void)
193194
}
194195
else
195196
{
196-
last = now;
197-
}
198-
199-
static oscore_time lastfps = 0;
200-
static int frames = 0;
201-
oscore_time elapsedfps = now - lastfps;
202-
frames++;
203-
if(elapsedfps > 2000000)
204-
{
205-
printf("%.2lf\n", (double)frames / (elapsedfps / 1000000.0));
206-
lastfps = now;
207-
frames = 0;
197+
last = now;
208198
}
209199

210200
for (int i = 0; i < HEIGHT; ++i)
@@ -214,7 +204,7 @@ int render(void)
214204
/* Send line packet */
215205
if (sendto(sockfd, line, sizeof(line)/sizeof(line[0]), 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) < 0)
216206
{
217-
printf("Send line %d failed\n", i);
207+
perror("Send line failed");
218208
}
219209
}
220210

@@ -223,7 +213,7 @@ int render(void)
223213
/* Send bufferswap packet */
224214
if (sendto(sockfd, bufferswap, sizeof(bufferswap)/sizeof(bufferswap[0]), 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) < 0)
225215
{
226-
printf("Send bufferswap failed\n");
216+
perror("Send bufferswap failed");
227217
}
228218

229219
return 0;

0 commit comments

Comments
 (0)