@@ -124,7 +124,7 @@ int init(void) {
124
124
struct ifreq if_idx ;
125
125
126
126
/* 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 )
128
128
{
129
129
perror ("socket" );
130
130
}
@@ -183,6 +183,7 @@ int clear(int _modno)
183
183
184
184
int render (void )
185
185
{
186
+ // Limit frame rate. In this configuration, the matrix is only stable up to ~70fps
186
187
static oscore_time last = 0 ;
187
188
oscore_time now = udate ();
188
189
oscore_time elapsed = now - last ;
@@ -193,18 +194,7 @@ int render(void)
193
194
}
194
195
else
195
196
{
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 ;
208
198
}
209
199
210
200
for (int i = 0 ; i < HEIGHT ; ++ i )
@@ -214,7 +204,7 @@ int render(void)
214
204
/* Send line packet */
215
205
if (sendto (sockfd , line , sizeof (line )/sizeof (line [0 ]), 0 , (struct sockaddr * )& socket_address , sizeof (struct sockaddr_ll )) < 0 )
216
206
{
217
- printf ("Send line %d failed\n" , i );
207
+ perror ("Send line failed" );
218
208
}
219
209
}
220
210
@@ -223,7 +213,7 @@ int render(void)
223
213
/* Send bufferswap packet */
224
214
if (sendto (sockfd , bufferswap , sizeof (bufferswap )/sizeof (bufferswap [0 ]), 0 , (struct sockaddr * )& socket_address , sizeof (struct sockaddr_ll )) < 0 )
225
215
{
226
- printf ("Send bufferswap failed\n " );
216
+ perror ("Send bufferswap failed" );
227
217
}
228
218
229
219
return 0 ;
0 commit comments